# Android 9: Sqlcipher crash

**URL:** <https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013>\
**Category:** Issues\
**Created:** [November 4, 2019, 6:31pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013 "2019-11-04T18:31:54Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![rsarma](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@rsarma](https://discuss.zetetic.net/u/rsarma)\
**Post date:** [November 4, 2019, 6:31pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/1 "2019-11-04T18:31:55Z")

</div>

**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)

 ![Crash](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/2X/5/5a339f76493a22a41bedb713c4b3cb93a67e2ef5.png)  
 ![30%20PM](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/2X/2/29378f71a41ef2ba38b7bc5015b3ac8b4934ea08.png)

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.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [November 4, 2019, 9:38pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/2 "2019-11-04T21:38:46Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rsarma](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@rsarma](https://discuss.zetetic.net/u/rsarma)\
**Post date:** [November 4, 2019, 9:56pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/3 "2019-11-04T21:56:51Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![grishav](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@grishav](https://discuss.zetetic.net/u/grishav)\
**Post date:** [December 29, 2019, 2:29pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/4 "2019-12-29T14:29:56Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![sjlombardo](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/sjlombardo/32/3_2.png) [@sjlombardo](https://discuss.zetetic.net/u/sjlombardo)\
**Post date:** [December 29, 2019, 3:48pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/5 "2019-12-29T15:48:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rsarma](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@rsarma](https://discuss.zetetic.net/u/rsarma)\
**Post date:** [January 30, 2020, 9:49pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/6 "2020-01-30T21:49:44Z")

</div>

@grishav Did consuming 4.3.0 resolve the issue for you ?

---

<div class="post-metadata">

**Author:** ![grishav](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@grishav](https://discuss.zetetic.net/u/grishav)\
**Post date:** [January 30, 2020, 10:19pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/7 "2020-01-30T22:19:46Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![rsarma](https://avatars.discourse-cdn.com/v4/letter/r/ac91a4/32.png) [@rsarma](https://discuss.zetetic.net/u/rsarma)\
**Post date:** [January 30, 2020, 10:46pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/8 "2020-01-30T22:46:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [January 31, 2020, 1:24pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/9 "2020-01-31T13:24:57Z")

</div>

Hello @rsarma

SQLCipher 4.3.0 is now available publicly. Thanks!

---

<div class="post-metadata">

**Author:** ![grishav](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@grishav](https://discuss.zetetic.net/u/grishav)\
**Post date:** [April 12, 2020, 12:50pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/10 "2020-04-12T12:50:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [April 13, 2020, 2:43pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/11 "2020-04-13T14:43:04Z")

</div>

Hi @grishav

Are you able to reliably reproduce the behavior? Possibly within the SQLCipher for Android [test suite](https://github.com/sqlcipher/sqlcipher-android-tests)?

---

<div class="post-metadata">

**Author:** ![grishav](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@grishav](https://discuss.zetetic.net/u/grishav)\
**Post date:** [April 13, 2020, 3:23pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/12 "2020-04-13T15:23:56Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![grishav](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@grishav](https://discuss.zetetic.net/u/grishav)\
**Post date:** [April 30, 2020, 6:45am UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/13 "2020-04-30T06:45:28Z")

</div>

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](https://discuss.zetetic.net/uploads/short-url/1SSVqdgjd5WgntsJXxx1DcVICeV.png)

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [April 30, 2020, 1:15pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/14 "2020-04-30T13:15:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![grishav](https://avatars.discourse-cdn.com/v4/letter/g/34f0e0/32.png) [@grishav](https://discuss.zetetic.net/u/grishav)\
**Post date:** [April 30, 2020, 1:42pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/15 "2020-04-30T13:42:20Z")

</div>

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.

 ![sqlcipher_crashes](https://us1.discourse-cdn.com/flex016/uploads/zetetic/original/2X/a/afa278c01aa133a4a3dc47d89567df8f1b1ba819.png)

---

<div class="post-metadata">

**Author:** ![developernotes](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/developernotes/32/1309_2.png) [@developernotes](https://discuss.zetetic.net/u/developernotes)\
**Post date:** [April 30, 2020, 7:51pm UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/16 "2020-04-30T19:51:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Redrazors](https://sea2.discourse-cdn.com/flex016/user_avatar/discuss.zetetic.net/redrazors/32/1976_2.png) [@Redrazors](https://discuss.zetetic.net/u/Redrazors)\
**Post date:** [October 10, 2020, 9:44am UTC](https://discuss.zetetic.net/t/android-9-sqlcipher-crash/4013/17 "2020-10-10T09:44:08Z")

</div>

Edit: my issue was due to android 29 permissions, so I’ve deleted the comment.
