FirebirdSQL/firebird

Firebird 5 crash on Android API level 34

hgourvest opened this issue · 15 comments

Steps to reproduce.

  1. Get Android sample app from here and open it with Android Studio.
  2. Install Android embedded version Firebird-5.0.0.1306-0-android-embedded.aar in the app/libs folder.
  3. Follow the instructions in the README file
  4. Create a virtual device using an API 34-level image.
  5. Run the application on the virtual device.
  6. It should crash on "attachDatabase"

The problem also occurs on a physical device. I have not been able to reproduce the problem on versions below 34.

Logcat

2024-05-09 19:02:46.690  7036-7036  libc                    com.example.firebirdandroidcpp       A  FORTIFY: fcntl(F_SETFD) passed non-FD_CLOEXEC flag: 0x80000
2024-05-09 19:02:46.690  7036-7036  libc                    com.example.firebirdandroidcpp       A  Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 7036 (ebirdandroidcpp), pid 7036 (ebirdandroidcpp)
2024-05-09 19:02:46.697  7036-7058  libEGL                  com.example.firebirdandroidcpp       D  loaded /vendor/lib64/egl/libGLESv1_CM_emulation.so
2024-05-09 19:02:46.703  7036-7058  libEGL                  com.example.firebirdandroidcpp       D  loaded /vendor/lib64/egl/libGLESv2_emulation.so
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A  Cmdline: com.example.firebirdandroidcpp
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A  pid: 7036, tid: 7036, name: ebirdandroidcpp  >>> com.example.firebirdandroidcpp <<<
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #03 pc 00000000002ce70d  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #04 pc 00000000002ce87b  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #05 pc 00000000002e6b9c  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #06 pc 00000000002e6ab6  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #07 pc 00000000002e5dc1  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #08 pc 00000000002e5c90  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #09 pc 00000000002e37f8  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #10 pc 00000000002e47cf  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #11 pc 00000000001cc638  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #12 pc 0000000000199b80  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #13 pc 000000000017cd55  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #14 pc 000000000013a3b5  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfbclient.so (offset 0x1c13000)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #15 pc 0000000000016072  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfirebirdandroidcpp.so (offset 0x16d4000) (Firebird::IAttachment* Firebird::IProvider::attachDatabase<Firebird::ThrowStatusWrapper>(Firebird::ThrowStatusWrapper*, char const*, unsigned int, unsigned char const*)+130) (BuildId: 327bca5327550877c0268fdff5881f1b0b0ff98c)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #16 pc 000000000001546c  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfirebirdandroidcpp.so (offset 0x16d4000) (BuildId: 327bca5327550877c0268fdff5881f1b0b0ff98c)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #17 pc 000000000001537f  /data/app/~~f4E1jxoFewkjflbT_SUu4Q==/com.example.firebirdandroidcpp-y7YDymswvBk_oO-hNZNNxQ==/base.apk!libfirebirdandroidcpp.so (offset 0x16d4000) (Java_com_example_firebirdandroidcpp_MainActivity_connect+63) (BuildId: 327bca5327550877c0268fdff5881f1b0b0ff98c)
2024-05-09 19:02:47.074  7062-7062  DEBUG                   pid-7062                             A        #24 pc 0000000000000598  <anonymous:794264600000> (com.example.firebirdandroidcpp.MainActivity.onCreate+0)

I think it's linked to this code in Firebird

the crash would be triggered by this change in Android AOSP

more info here

Could you try to build with change O_CLOEXEC by FD_CLOEXEC ?

I've never compiled Firebird, so if you can point me in the right direction for Android, I'd like to give it a try.

Sorry, I was under impression that you build FB yourself.
Another idea - I can commit this change at separate branch and you should be able to use snapshot build of that branch.
Is it OK for you ?

that would be perfect, I have a concurrent access test to the client library, that should allow me to validate this modification.

Already pushed the branch with it :)
The build artifacts will be available here soon
https://github.com/FirebirdSQL/firebird/actions/runs/9081677086

Android builds are ready.

Thank you very much, I'll test this on as many architectures as possible and report back.

As far as I can tell, it works on Linux (x86_64), Mac Os (x86_64, aarch64), Android (armv7, armv8, x86_64).

Thank you for investigating the problem and testing the fix