realm-java icon indicating copy to clipboard operation
realm-java copied to clipboard

deadlock happens on specific device when using encryption example

Open tebica opened this issue 11 years ago • 23 comments

one of Korean developer having deadlock issue when using Realm encryption example.

They tried our encryption example and Realm.getInstance() function never returned.

This happens only on LG G3 phone with LG G3(LG-F460S / OS: 4.4.2)

  • They tried Realm v0.81.1 and v0.82 -> Not working
  • They tried other LG G3 phone (LG-F460S / OS: 4.4.2) -> Not working
  • if they comment .encryptionKey(key) line -> working fine
  • same phone with OS 5.0.1 -> working fine
  • other phones Galaxy Note2(SHV-E250S / OS 4.4.2) & Galaxy S5(SM-G906S / OS 4.4.2) -> working fine

below is the only log that they can see when this issue happening

07-30 22:47:03.282 17838-18303/com.kakao.hello D/dalvikvm﹕ Trying to load lib /data/app-lib/com.kakao.hello-1/librealm-jni.so 0x43029850 
07-30 22:47:03.282 17838-18303/com.kakao.hello D/dalvikvm﹕ Added shared lib /data/app-lib/com.kakao.hello-1/librealm-jni.so 0x43029850

tebica avatar Jul 31 '15 08:07 tebica

That does sounds a bit strange. Are there any form of device management software running on that device?

Also it could be interesting to see what happens if you could attach a debugger to see exactly where inside the Realm.getInstance() call it blocked.

cmelchior avatar Jul 31 '15 09:07 cmelchior

Please try this: 1 Set a breakpoint on getInstance

2 Start debuging, when the debugpoint reached, find the pid of the app by:

adb shell ps | grep <app name>

3 Use strace to get more information by:

adb shell run-as <app's package name> strace -f -p <the pid got from step 2>

4 Continue running the app

5 After it get stalled, send the strace log in the terminal to us.

Thanks!

beeender avatar Jul 31 '15 09:07 beeender

@cmelchior It's blocked at createNativeWithImplicitTransactions() method.

SharedGroup.java

57    public SharedGroup(String databaseFile, boolean enableImplicitTransactions, Durability durability, byte[] key) {
58        if (enableImplicitTransactions) {
59            nativeReplicationPtr = nativeCreateReplication(databaseFile, key);
60            nativePtr = createNativeWithImplicitTransactions(nativeReplicationPtr, durability.value, key);
61            implicitTransactionsEnabled = true;
62        } else {
63            nativePtr = nativeCreate(databaseFile, Durability.FULL.value, false, false, key);
64        }
65        context = new Context();
66        path = databaseFile;
67        checkNativePtrNotZero();
78    }

I have attached a screenshot. 2015-07-31 8 17 00

jungilhan avatar Jul 31 '15 11:07 jungilhan

@jungilhan Do you know which version of the Android System WebView that is installed on the device? https://play.google.com/store/apps/details?id=com.google.android.webview&hl=en

It might seem completely unrelated, but they had an old bug that might effect this

cmelchior avatar Jul 31 '15 11:07 cmelchior

@cmelchior Android System WebView is not installed on the device.

device-2015-07-31-210034

jungilhan avatar Jul 31 '15 12:07 jungilhan

@beeender I have tried, But I can't see any trace output.

jungilhan avatar Jul 31 '15 12:07 jungilhan

@jungilhan Can you please paste the output in the terminal from step 2 & 3 here?

beeender avatar Jul 31 '15 12:07 beeender

@beeender I got message "run-as: exec failed for strace Error:Permission denied".

2015-07-31 9 40 33

jungilhan avatar Jul 31 '15 12:07 jungilhan

@jungilhan That is strange... strace should not ask for root permission... Try strace with su if your phone is rooted.

Or, even simpler, open the app, wait there until ANR happens, then send the whole logcat to us. Then there should be a native backtrace in.

beeender avatar Jul 31 '15 12:07 beeender

@beeender Hmmm... ANR dialog is not showing. Please see the attached video and log.

  • https://dl.dropboxusercontent.com/u/539401/realm/IMG_1285.MOV
  • https://dl.dropboxusercontent.com/u/539401/realm/log

Another LG G3(LG-F460S / OS: 4.4.2) phone gives the same result.

jungilhan avatar Jul 31 '15 14:07 jungilhan

I think you will only get an ANR if there is another event it cannot respond to, like if you touched the screen. Said said, that doesn't have any impact on why it is hanging. Thank you for trying with another phone as well.

cmelchior avatar Jul 31 '15 14:07 cmelchior

Isolating the .so in question just to be extra paranoid. Remove all native libs from 0.82 jar except for armv7. This should confirm the phone is running on the correct .so and not the arm one.

Qubitium avatar Aug 02 '15 00:08 Qubitium

@diegomontoya Could you explain to me how to remove so files from realm-0.82.0.jar?

jungilhan avatar Aug 04 '15 13:08 jungilhan

Just rename the realm jar file extension to .zip, unzip it, remove the unwanted .so files, zip it again and rename it to .jar

emanuelez avatar Aug 04 '15 13:08 emanuelez

@emanuelez I got build error below, 2015-08-04 10 24 36

jungilhan avatar Aug 04 '15 13:08 jungilhan

That looks like Realm is not loaded at all. Can I see your build.gradle file ?

emanuelez avatar Aug 04 '15 14:08 emanuelez

@jungilhan if on Windows, just use 7zip to right click open the jar file (open archive) and delete the libs/xxx folders you don't want.

Qubitium avatar Aug 04 '15 22:08 Qubitium

@emanuelez @nhachicha , Here is the project file that he is using. https://dl.dropboxusercontent.com/u/539401/encryption%203.zip which has the build.gradle in it. Can you kindly check? app/libs/realm-0.82.0.jar -> has all .so app/libs/realm-0.82.0-strip.jar -> has v7a only

tebica avatar Aug 05 '15 06:08 tebica

@tebica I had a friend testing the APK on a G2 LG-D802 & it works [ro.product.model]: [LG-D802] Is it working as well for the OP on a LG G2 ?

nhachicha avatar Aug 05 '15 15:08 nhachicha

@nhachicha : It seems like issue happens only G3 specific model LG-F460S (Korea model) Not reproducible on G2. I have the specific model LG-F460S on my hand. What should be the next thing that I should check?

tebica avatar Aug 10 '15 16:08 tebica