Android 9: Sqlcipher crash

Issue: SIGSEGV on Android 9. Sqlcipher version is 4.2.0

Devices: Please refer the playconsole screenshot.

Reproduction: We are still trying to get hold of one of the devices to repro it locally.

Crash:
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)
/system/lib/libc.so (pthread_mutex_lock+4)
/data/app/com.airwatch.androidagent-hUDXxLZdlcLi3sWQnK0LLQ==/lib/arm/libsqlcipher.so (sqlite3_bind_text16+18)


Not sure how much of a help this stacktrace is (#pc values could help you with narrowing the flow where the crash occured), thought it would be good to report the bug and help zetetic team with next steps.

Hi @rsarma

Thanks for sharing the crash information. A few follow-up questions regarding the crash:

  • Do you have any sense of the code execution within your application that is causing this crash?
  • Do you happen to know what Android OS version the devices reporting the crash are running?

@developernotes Not sure at what point the crash occurs (app startup or a workflow), except that it is during a Sqlcipher query. This only occurs on Android 9 devices.

Hello @developernotes, we experience the same issue. In our case the crash stack varies sometimes - app crashes in sqlite3_reset, sqlite3_bind_text16 or sqlite3_step. But pthread_mutex_lock is always on the top of crash stack.
Sqlcipher version is 4.2.0 . Android 9 in all cases here as well.

This thread is two months old - have you found any solution to this meanwhile?
Thanks!

Hello @grishav, Can you please upgrade to 4.3.0? The new version includes changes to the mutex initialization and locking in the OpenSSL provider used for Android. Please report back to us whether you still observe the problem in 4.3.0.

@grishav Did consuming 4.3.0 resolve the issue for you ?

The version of our application containing the new Sqlcipher version wasn’t released yet, so I don’t know for sure. I never reproduced this error in my test environment with old version as well - I just see a lot of crashes from my users on Google Play. So unfortunately I can’t be sure until we will release our app to production.

Thanks for the quick response. Once you release with the change, do please keep the thread updated.

Hello @rsarma

SQLCipher 4.3.0 is now available publicly. Thanks!

Hello,
Now when we released a version with SQLCipher 4.3.0, I can confirm that this bug is still there, on Android 9 devices.
@developernotes
Can you suggest any solution?
Thanks.

Hi @grishav

Are you able to reliably reproduce the behavior? Possibly within the SQLCipher for Android test suite?

Hi @developernotes,
The answer is no… I wasn’t able to reproduce this on my devices - not even once. I only can see the numerous crashes of my app on Google Play, all with very similar stack trace.

I have some background service in my app which occasionally writes to the database some information in response to system events. I suspect that the app crashes when the service tries to update the database at the same time when main activity writes to it. Though I do use locks to prevent this, but probably it’s not good enough. Anyway, I expected to get some exception which I can catch in this case and not the native crash of the application…

Hello @developernotes,
How can I help to investigate this further?
I have a lot of crash reports on Google Play and all of them, 100%, are inside sqlcipher code. This is very frustrating…
Please help!
Thanks.
Crashes|690x372

Hi @grishav

Do you have a stack trace you can share? Can you provide details such as the code that is executing around the crash site, along with device and Android OS version information regarding the crash? Unfortunately, a SIGSEGV is not enough information to track down what is occurring within your application.

Hi @developernotes,
I understand of course that SIGSEGV is not enough.
But I have no idea about the exact scenario or executing code.
I’m attaching stack traces of some of the reports as shown on Google Play, including device and OS. Hopefully this will be helpful for you (though I can’t see any valuable information in this).
Thanks again.

Hello @grishav

Unfortunately, that does not provide the additional details necessary to further diagnose the situation that is causing a crash in your application other than it appears you are iterating through a result-set. Any additional information you can share would be helpful.