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

Why some user always crash in Java_io_objectbox_query_Query_nativeRemove

Open 15915763299 opened this issue 1 year ago • 6 comments
trafficstars

the main thread stack:

0 | #00 pc 000000000016de8c /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
-- | --
1 | #01 pc 0000000000173964 /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
2 | #02 pc 00000000001708dc /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
3 | #03 pc 000000000016ffec /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
4 | #04 pc 0000000000167e7c /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
5 | #05 pc 00000000000f5870 /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
6 | #06 pc 00000000000f73b0 /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
7 | #07 pc 00000000000ef248 /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
8 | #08 pc 0000000000139b84 /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so
9 | #09 pc 00000000000b4280 /data/app/com.jglive.xinlian-vX1snvu_bJtycHbpp_MNYg==/lib/arm64/libobjectbox-jni.so (Java_io_objectbox_query_Query_nativeRemove+68)
10 | #10 pc 0000000000152354 /apex/com.android.runtime/lib64/libart.so
11 | #11 pc 0000000000149338 /apex/com.android.runtime/lib64/libart.so
12 | #12 pc 00000000001581b8 /apex/com.android.runtime/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+256)
13 | #13 pc 000000000030014c /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_11ShadowFrameEtPNS_6JValueE+388)
14 | #14 pc 00000000002fb41c /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+916)
15 | #15 pc 00000000005d365c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+652)
16 | #16 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
17 | #17 pc 00000000005d5d08 /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+1172)
18 | #18 pc 0000000000143918 /apex/com.android.runtime/lib64/libart.so
19 | #19 pc 00000000005d6514 /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+1140)
20 | #20 pc 0000000000143998 /apex/com.android.runtime/lib64/libart.so
21 | #21 pc 00000000005d516c /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1756)
22 | #22 pc 0000000000143a18 /apex/com.android.runtime/lib64/libart.so
23 | #23 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
24 | #24 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
25 | #25 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
26 | #26 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
27 | #27 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
28 | #28 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
29 | #29 pc 00000000005d516c /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1756)
30 | #30 pc 0000000000143a18 /apex/com.android.runtime/lib64/libart.so
31 | #31 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
32 | #32 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
33 | #33 pc 00000000005d516c /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1756)
34 | #34 pc 0000000000143a18 /apex/com.android.runtime/lib64/libart.so
35 | #35 pc 00000000002d0a78 /apex/com.android.runtime/lib64/libart.so
36 | #36 pc 00000000005c2994 /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1016)
37 | #37 pc 000000000015246c /apex/com.android.runtime/lib64/libart.so
38 | #38 pc 00000000003d8d5c /system/framework/arm64/boot.oat
39 | null

What dost code in "Java_io_objectbox_query_Query_nativeRemove+68" do? Once crash happen, the same user will crash many times.

my code:

    private fun deleteExpireTimeData() {
        try {
            val splitTime =
                System.currentTimeMillis() / 1000 - AppConfigManager.getOnlineMaxSaveTime()
            val count = getOnlineUserBox().query()
                .less(OnlineNoticeUserEntity_.pullServerTime, splitTime)
                .build()
                .remove()
        } catch (e: Exception) {
            val dir = onlineDataDir()
            FileUtils.delete(dir)
        }
    }

It's crash when 'remove' invoke

15915763299 avatar Oct 30 '24 07:10 15915763299

Thanks for reporting! It would really help if you can provide the info requested in the bug report template, most importantly which version of ObjectBox is used by your project?

Anyhow, the most common cause for this, that we are aware of, is that the Store is closed in a different thread while the remove query is still running.

Note: I labeled this issue with "more info required" so it will auto-close in a few days if there are no follow-up comments.

greenrobot-team avatar Oct 30 '24 08:10 greenrobot-team

Build info ObjectBox version: [3.8.0] OS: [Android 28/29/30 ] Device/ABI/architecture: [arm64-v8a / armeabi-v7a / armeabi(8 Cores)]

Recently, it's crash 101 times in 3 phones as below: HUAWEI EVR-AN00, Android 29 vivo V1945A, Android 28 OPPO PECM30, Android 31 image

Steps to reproduce when the app launch and invoke 'remove' method`

    private fun deleteExpireTimeData() {
        try {
            val splitTime =
                System.currentTimeMillis() / 1000 - AppConfigManager.getOnlineMaxSaveTime()
            val count = getOnlineUserBox().query()
                .less(OnlineNoticeUserEntity_.pullServerTime, splitTime)
                .build()
                .remove()
        } catch (e: Exception) {
            val dir = onlineDataDir()
            FileUtils.delete(dir)
        }
    }

the stack traces is in the first message

15915763299 avatar Oct 31 '24 05:10 15915763299

objectboxVersion = '3.8.0'

implementation "io.objectbox:objectbox-kotlin:$objectboxVersion"
normalImplementation "io.objectbox:objectbox-android:$objectboxVersion"
forTestImplementation "io.objectbox:objectbox-android-objectbrowser:$objectboxVersion"
kapt "io.objectbox:objectbox-processor:$objectboxVersion"

classpath("io.objectbox:objectbox-gradle-plugin:$objectboxVersion")

15915763299 avatar Oct 31 '24 05:10 15915763299

Based on the symbolized crash dump ending in LMDB code, this likely is as I suspected because the Store gets closed while a query is running.

The latest release has improvements for that case. My recommendation is to update to the latest version (4.0.3 as of 2024-11-04).

Edit: internal issue is objectbox-java#244

Note: I labeled this issue with "more info required" so it will auto-close in a few days if there are no follow-up comments.

greenrobot-team avatar Nov 04 '24 08:11 greenrobot-team

Thanks, I will try it in next version of our app.

15915763299 avatar Nov 04 '24 09:11 15915763299

There are some new crash in ObjectBox version 4.0.3

Build info ObjectBox version: [4.0.3] OS: [Android 29] ABI/architecture: [arm64-v8a / armeabi-v7a / armeabi(8 Cores)] Device: HUAWEI EVR-AN00

Stack traces

#00 pc 00000000001c5944 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#01 pc 00000000001cb5c8 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#02 pc 00000000001c84e4 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#03 pc 00000000001c7b8c /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#04 pc 00000000001bf820 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#05 pc 000000000012acf8 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#06 pc 000000000012c838 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#07 pc 0000000000123cd0 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#08 pc 000000000017fe88 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so
#09 pc 00000000000dd2e4 /data/app/com.jglive.xinlian-Jq2Bbr2ljlIeTagH-4BOxw==/lib/arm64/libobjectbox-jni.so (Java_io_objectbox_query_Query_nativeRemove+72)
#10 pc 0000000000152354 /apex/com.android.runtime/lib64/libart.so
#11 pc 0000000000149338 /apex/com.android.runtime/lib64/libart.so
#12 pc 00000000001581b8 /apex/com.android.runtime/lib64/libart.so (_ZN3art9ArtMethod6InvokeEPNS_6ThreadEPjjPNS_6JValueEPKc+256)
#13 pc 000000000030014c /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreter34ArtInterpreterToCompiledCodeBridgeEPNS_6ThreadEPNS_9ArtMethodEPNS_11ShadowFrameEtPNS_6JValueE+388)
#14 pc 00000000002fb41c /apex/com.android.runtime/lib64/libart.so (_ZN3art11interpreter6DoCallILb0ELb0EEEbPNS_9ArtMethodEPNS_6ThreadERNS_11ShadowFrameEPKNS_11InstructionEtPNS_6JValueE+916)
#15 pc 00000000005d365c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+652)
#16 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
#17 pc 00000000005d5d08 /apex/com.android.runtime/lib64/libart.so (MterpInvokeDirect+1172)
#18 pc 0000000000143918 /apex/com.android.runtime/lib64/libart.so
#19 pc 00000000005d6514 /apex/com.android.runtime/lib64/libart.so (MterpInvokeStatic+1140)
#20 pc 0000000000143998 /apex/com.android.runtime/lib64/libart.so
#21 pc 00000000005d516c /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1756)
#22 pc 0000000000143a18 /apex/com.android.runtime/lib64/libart.so
#23 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
#24 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
#25 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
#26 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
#27 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
#28 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
#29 pc 00000000005d516c /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1756)
#30 pc 0000000000143a18 /apex/com.android.runtime/lib64/libart.so
#31 pc 00000000005d396c /apex/com.android.runtime/lib64/libart.so (MterpInvokeVirtual+1436)
#32 pc 0000000000143818 /apex/com.android.runtime/lib64/libart.so
#33 pc 00000000005d516c /apex/com.android.runtime/lib64/libart.so (MterpInvokeInterface+1756)
#34 pc 0000000000143a18 /apex/com.android.runtime/lib64/libart.so
#35 pc 00000000002d0a78 /apex/com.android.runtime/lib64/libart.so
#36 pc 00000000005c2994 /apex/com.android.runtime/lib64/libart.so (artQuickToInterpreterBridge+1016)
#37 pc 000000000015246c /apex/com.android.runtime/lib64/libart.so
#38 pc 00000000003d8d5c /system/framework/arm64/boot.oat

15915763299 avatar Nov 26 '24 02:11 15915763299