Tencent / MMKV

An efficient, small mobile key-value storage framework developed by WeChat. Works on Android, iOS, macOS, Windows, and POSIX.
Other
17.2k stars 1.89k forks source link

crash with MMKV.getInt[DEDUPED] #1264

Closed hulong121 closed 4 months ago

hulong121 commented 4 months ago

Hi, we found crash on our online app, we can't reproduce on our local device, MMKV's version is 1.2.16, crash devices are Alcatel Kona, motorola aruba, samsung a3core with Android OS 11 and 13, our code like this:

  1. MMKV.initialize(c, MMKVLogLevel.LevelNone);
  2. MMKV instance= MMKV.mmkvWithID(fileName, MMKV.SINGLE_PROCESS_MODE, dky);
  3. int tmp = instance.getInt("xxxx|i", 0);

crash stack trace is:


pid: 0, tid: 18339 >>> com.xxx.xxx <<<

backtrace:

00 pc 0x000000000003b62c /apex/com.android.runtime/lib/bionic/libc.so (arena_slab_reg_alloc+100)

01 pc 0x000000000003bb8b /apex/com.android.runtime/lib/bionic/libc.so (je_arena_malloc_hard+174)

02 pc 0x00000000000324e7 /apex/com.android.runtime/lib/bionic/libc.so (je_malloc+1314)

03 pc 0x000000000002c513 /apex/com.android.runtime/lib/bionic/libc.so (malloc+18)

04 pc 0x0000000000046be7 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (operator new(unsigned int)+14) (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

05 pc 0x000000000004723b /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (std::ndk1::basic_string<char, std::__ndk1::char_traits, std::ndk1::allocator >::__init_copy_ctor_external(char const*, unsigned int)+42) (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

06 pc 0x0000000000047209 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (std::ndk1::basic_string<char, std::__ndk1::char_traits, std::ndk1::allocator >::basic_string(std::ndk1::basic_string<char, std::__ndk1::char_traits, std::ndk1::allocator > const&)+32) (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

07 pc 0x000000000003e383 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

08 pc 0x000000000003e33d /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

09 pc 0x000000000003e2fb /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

10 pc 0x000000000003e2b1 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

11 pc 0x000000000003e269 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

12 pc 0x000000000003e1b1 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

13 pc 0x000000000003df17 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

14 pc 0x000000000003ddd1 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

15 pc 0x000000000003d459 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

16 pc 0x000000000003d311 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

17 pc 0x000000000003d67d /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

18 pc 0x000000000003078f /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

19 pc 0x00000000000313a3 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

20 pc 0x0000000000031dc9 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

21 pc 0x000000000002473b /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

22 pc 0x000000000001e4b1 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/base.apk!libmmkv.so (BuildId: e99ac0e15ecb683f8721ac4fcfbc9eb1f2761004)

23 pc 0x00000000001ad717 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/oat/arm/base.odex (art_jni_trampoline+118)

24 pc 0x00000000003c40c7 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/oat/arm/base.odex (com.tencent.mmkv.MMKV.getInt [DEDUPED]+54)

25 pc 0x000000000029fc19 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/oat/arm/base.odex (x.f.g+712)

26 pc 0x00000000003440df /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/oat/arm/base.odex (com.mysdk.m.t.s.h.C+1070)

27 pc 0x0000000000346ca3 /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/oat/arm/base.odex (com.mysdk.m.t.s.h.i+66)

28 pc 0x00000000002e3b5d /data/app/~~Ppqg7ppYjg5Doe6MmXFdtw==/com.xxx.xxx-K6YNDqLLLKHnJj206AdVRQ==/oat/arm/base.odex (c3.a8.run+124)

29 pc 0x00000000005a4e51 /system/framework/arm/boot-framework.oat (android.os.Handler.dispatchMessage+64)

30 pc 0x00000000005a7889 /system/framework/arm/boot-framework.oat (android.os.Looper.loop+1352)

31 pc 0x00000000005a68c7 /system/framework/arm/boot-framework.oat (android.os.HandlerThread.run+478)

32 pc 0x00000000000d49d5 /apex/com.android.art/lib/libart.so (art_quick_invoke_stub_internal+68)

33 pc 0x00000000004bd3d3 /apex/com.android.art/lib/libart.so (art_quick_invoke_stub+294)

34 pc 0x0000000000123631 /apex/com.android.art/lib/libart.so (art::ArtMethod::Invoke(art::Thread, unsigned int, unsigned int, art::JValue, char const)+148)

35 pc 0x00000000003e261f /apex/com.android.art/lib/libart.so (art::(anonymous namespace)::InvokeWithArgArray(art::ScopedObjectAccessAlreadyRunnable const&, art::ArtMethod, art::(anonymous namespace)::ArgArray, art::JValue, char const)+54)

36 pc 0x00000000003e3411 /apex/com.android.art/lib/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<art::ArtMethod>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject, art::ArtMethod, jvalue const)+356)

37 pc 0x00000000003e359f /apex/com.android.art/lib/libart.so (art::JValue art::InvokeVirtualOrInterfaceWithJValues<_jmethodID>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject, _jmethodID, jvalue const)+42)

38 pc 0x000000000042311f /apex/com.android.art/lib/libart.so (art::Thread::CreateCallback(void*)+1066)

39 pc 0x00000000000b0547 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+40)

40 pc 0x0000000000066b17 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30)

please help, thanks.

lingol commented 4 months ago

Please provide symbolized call stacks of MMKV, plus the logs from logcat. Without such information, it is impossible to do any investigation. And the issue will be closed.

hulong121 commented 4 months ago

@lingol Hi, this crash is on our online app, we can't reproduce local, so we have no logs from logcat... i will try to symbolized call stacks of MMKV, on the other hand, can you please provide some suggetion so that we can bypass this issue as a workround? thanks.

lingol commented 4 months ago

You don't necessarily need to reproduce it to collect logs from logcat. Any capable crash report system can collect it for you.

lingol commented 4 months ago

on the other hand, can you please provide some suggetion so that we can bypass this issue as a workround? thanks.

Without investigation, there can not be any valid suggestion.

hulong121 commented 4 months ago

You don't necessarily need to reproduce it to collect logs from logcat. Any capable crash report system can collect it for you.

Hi, we use google play to collect crash, but i didn't find any logs from google play console. and i can't provide symbolized call stacks of MMKV, because i have no symbol file. i also checked other crash on Firebase crashlytics, and didn't find any logs, which crash report system can collect logs from logcat? we can add it. thanks

lingol commented 4 months ago

and i can't provide symbolized call stacks of MMKV, because i have no symbol file.

No excuse for that. It's on Maven Central.

lingol commented 4 months ago

which crash report system can collect logs from logcat?

I heard bugly can do that. https://mp.weixin.qq.com/s/g-WzYF3wWAljok1XjPoo7w

hulong121 commented 4 months ago

I heard bugly can do that. https://mp.weixin.qq.com/s/g-WzYF3wWAljok1XjPoo7w

got it, i will try to integrate with bugly

hulong121 commented 4 months ago

@lingol Hi, i got some news, i used the MMKV.SINGLE_PROCESS_MODE to init MMKV instance, these days we meet crash with decodeString() on our local device, and can reproduce if we didn't clear app's data, we change the mode from MMKV.SINGLE_PROCESS_MODE to MMKV.MULTI_PROCESS_MODE and the crash disappear, but our app only one process, i don't know why MMKV.SINGLE_PROCESS_MODE can't work, our other app also used MMKV.SINGLE_PROCESS_MODE and have no crash issue.

lingol commented 4 months ago

we change the mode from MMKV.SINGLE_PROCESS_MODE to MMKV.MULTI_PROCESS_MODE and the crash disappear

If that's the case, you must be using it in multiple processes. For example, a Service is in a separated process.