Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANR while SQLiteDatabase.loadLibs #519

Open
arvifox opened this issue Sep 8, 2020 · 10 comments
Open

ANR while SQLiteDatabase.loadLibs #519

arvifox opened this issue Sep 8, 2020 · 10 comments
Labels
enhancement A software enhancement for SQLCipher for Android

Comments

@arvifox
Copy link

arvifox commented Sep 8, 2020

Expected Behavior

Actual Behavior

I get an ANR during SQLiteDatabase.loadLibs(context).
I use ContentProvider to initialize the database and sqlcipher because my application works in background.
I call the loadLibs() method in the ContentProvider.
The ANR happens only on Samsung S20, S20+, S20 Ultra on Andoroid 10 (OneUI 2.5) and only after reboot of a phone.
If user starts the application manually everything works well.
Also I use ndk.abiFilters 'armeabi-v7a', 'arm64-v8a'
Please help me

Steps to Reproduce

SQLCipher version (can be identified by executing PRAGMA cipher_version;):

SQLCipher for Android version: 4.4.0

@developernotes
Copy link
Member

Hi @arvifox

If you remove your ABI filter, does the same behavior occur?

@arvifox
Copy link
Author

arvifox commented Sep 8, 2020

Hi @developernotes
The same behavior occurs.
In logfile I see these lines about 2 minutes after SQLiteDatabase.loadLibs is called.

mypackagename: Thread[5,tid=7781,WaitingInMainSignalCatcherLoop,Thread*=0x70b42a0400,peer=0x12e81738,"Signal Catcher"]: reacting to signal 3
mypackagename: Wrote stack traces to tombstoned

@developernotes
Copy link
Member

Hello @arvifox

The next step is to isolate your application and logic from the library to verify that integration usage isn't the cause. Would you try recreating the issue in isolation within the SQLCipher for Android test suite. We would be happy to review a reproduction case.

@arvifox
Copy link
Author

arvifox commented Sep 9, 2020

Hello @developernotes
I tested within test suite.

Behaviiour Test suite Passed: 114, Failed: 0
Support Test suit: Passed: 99, Failed: 0

Then I created new ContentProvider, just copypasted from ZeteticContentProvider and added

Log.i("foxxx", "content provider create");
SQLiteDatabase.loadLibs(getContext().getApplicationContext());
Log.i("foxxx", "content provider loadlibs done");

to OnCreate method.
everything works well if a user start application manually.
but if Contentprovider starts after reboot of a phone I dont see content provider loadlibs done line in logcat, and then I get ANR.
it is reproducible only on samsung s20 with OneUI 2.5 launcher.
BTW today morning I installed android 11 on my Pixel 4. Everything works well on android 11.

@developernotes
Copy link
Member

Hi @arvifox

Since you are only able to reproduce it on a Samsung s20, would you modify the content provider in the test suite to call this before you call loadLibs(...). I'm curious if you see consistent behavior.

try {
  Log.i("foxxx", "before loadLibrary");
  System.loadLibrary("sqlcipher");
  Log.i("foxxx", "after loadLibrary");
} catch (Throwable ex){
  Log.e("foxxx", "exception loading SQLCipher", ex);
}

@ghost
Copy link

ghost commented Sep 10, 2020

Hi @developernotes ,
I'm a colleague of @arvifox .

I tried your last approach and face the same issue. App stucks at System.loadLibrary("sqlcipher");.
If I try to load another library, this one works

@Override
protected Configuration getConfiguration() {
Log.i("foxxx", "doInit# init securelib start...");
 try {
    Log.i("foxxx", "before loadLibrary gdk");
    System.loadLibrary("gdk");
    Log.i("foxxx", "after loadLibrary gdk");
    Log.i("foxxx", "before loadLibrary sqlcipher");
    System.loadLibrary("sqlcipher");
    Log.i("foxxx", "after loadLibrary sqlcipher");
} catch (Throwable ex){
     Log.e("foxxx", "exception loading libraries", ex);
}
2020-09-10 09:33:53.597 1479-1479/com.arvifox.sqlcipherloadtest I/foxxx: doInit# init securelib start...
2020-09-10 09:33:53.597 1479-1479/com.arvifox.sqlcipherloadtest I/foxxx: before loadLibrary gdk
2020-09-10 09:33:53.606 1479-1479/com.arvifox.sqlcipherloadtest I/foxxx: after loadLibrary gdk
2020-09-10 09:33:53.606 1479-1479/com.arvifox.sqlcipherloadtest I/foxxx: before loadLibrary sqlcipher

@developernotes
Copy link
Member

Hi @arvifox, @andreas-schmidt-07,

Thank you for your follow-up. Due to the nature of the issue you are experiencing, it would be helpful for you to reach out to us directly at support@zetetic.net to discuss resolution options. Thanks!

@stale
Copy link

stale bot commented Sep 29, 2020

Hello, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "bug", "enhancement", or "security" and I will leave it open. Thank you for your contributions.

@stale stale bot added the stale This issue lacks recent activity. label Sep 29, 2020
@developernotes developernotes added enhancement A software enhancement for SQLCipher for Android and removed stale This issue lacks recent activity. labels Sep 29, 2020
@n0m0r3pa1n
Copy link

We are facing the same issue with the ANR in the exact same phones mentioned here? Any updates on this one @developernotes ?

@rsamoilenko
Copy link

We are facing the same issue on the same set of devices and only after system reboot. Might this be due to android:directBootAware="true" on our BroadcastReceiver that is triggered after reboot with BOOT_COMPLETED intent?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement A software enhancement for SQLCipher for Android
Projects
None yet
Development

No branches or pull requests

4 participants