Featured Android game crashes in libcocos2dcpp.so

My game, was kindly featured by Giftiz a couple of days ago and I landed 120 downloads which was nice. One has left me 1* rating with no comment but probably was the one who send a couple of crash reports to me. Please can anyone help me make sense of what I’m seeing here? The other report was identical from the backtrace down and shared the build finger print:

Native crash at /system/lib/libc.so in /system/lib/libc.so (tgkill+12), /system/lib/libc.so (pthread_kill+48)

Build fingerprint: ‘lge/x5_spr_us/x5:4.4.2/KOT49I.LS740ZV5/LS740ZV5.1417913828:user/release-keys’
Revision: ‘6’
pid: 21532, tid: 22073, name: Thread-2678 >>> uk.co.best_bit.pluckywords <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
r0 00000000 r1 00005639 r2 00000006 r3 00000000
r4 00000006 r5 00000016 r6 00005639 r7 0000010c
r8 63769d30 r9 620e1f28 sl 635a0548 fp 674fdb24
ip 674fd770 sp 674fd710 lr 40072205 pc 400811d4 cpsr 000f0010
d0 0000000000000000 d1 0000000000000000
d2 0000000000000000 d3 0000000000000000
d4 fecdfeccfec9feca d5 fecdfecefecffece
d6 fed3fed2fed1fed0 d7 fed5fed4fed1fed2
d8 0000000000000000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 674fddd06317fde8 d17 6317fde8ffffffff
d18 400a91846317fde8 d19 674fd760400a922c
d20 620e1f2863769d30 d21 674fdb24635a0548
d22 674fd760ffffdf1c d23 605dbf8b605dbf8b
d24 3f6e573ac0000000 d25 8000000000000000
d26 3ff0000000000000 d27 bf61111120000000
d28 8000000000000000 d29 0000000000000000
d30 0000000000000000 d31 0000000000000000
scr 28000013

backtrace:
#00 pc 000221d4 /system/lib/libc.so (tgkill+12)
#01 pc 00013201 /system/lib/libc.so (pthread_kill+48)
#02 pc 00013415 /system/lib/libc.so (raise+10)
#03 pc 0001214b /system/lib/libc.so
#04 pc 00021a88 /system/lib/libc.so (abort+4)
#05 pc 0039cacf /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2dcpp.so (__gnu_cxx::__verbose_terminate_handler()+230)

code around pc:
400811b4 e8bd00f0 e3700a01 912fff1e e2600000
400811c4 ea006e42 e92d50f0 e3a07f43 ef000000
400811d4 e8bd50f0 e3700a01 912fff1e e2600000
400811e4 ea006e3a e92d50f0 e3a070ee ef000000
400811f4 e8bd50f0 e3700a01 912fff1e e2600000
40081204 ea006e32 f200429a bf0080b9 f040f891
40081214 4001e92d f2c02a04 2a1080a5 8093f2c0
40081224 f2c02a20 2a408088 ea4fdb7f f1bc1c92
40081234 dd6c0f0a 0600e92d 0f40f1bc f500dd4a
40081244 f5016e80 ebae7920 ea4f0e09 ea4f5e4e
40081254 f50e5e5e ebbc7e20 dd3b1f9e f04fbfc4
40081264 ebd9090a dd35199e 0a0eeb01 0a3ff02a
40081274 1c9eebac bfd245e1 0c09ebac f04f46e1
40081284 f8910c00 f891f240 f921f280 f921028d
40081294 f8da428d f1b93000 f9000901 f900028d
400812a4 f10a428d d1ee0a40 0f00f1bc f5bcd02b

code around lr:
400721e4 447b4b13 42b3e010 6a1ed10e 44784811
400721f4 ec84f7fb ea20f00d 46224631 efe2f00e
40072204 d00a3001 e00b2400 2b00681b 480ad1eb
40072214 44782403 ec72f7fb f001e002 6804fa23
40072224 fa20f001 46206005 bf00bd70 0003b1ce
40072234 0003b1c2 0003b1ba 0003b196 bf7ef7ff
40072244 4a3e4b3d e92d447b b08b43f0 4606589c
40072254 6823460d 930946a1 fa04f001 8000f8d0
40072264 d0482d00 f0104628 280ff92f d8444604
40072274 ffe4f7ff d1064286 4629200f e8eaf00d
40072284 d03c2800 482ee02e f7fb4478 482debb6
40072294 e0154478 d11342b0 482b6a06 f7fb4478
400722a4 4a2aec2e 46332120 a801447a f9a6f013
400722b4 a8012101 fcc4f01a 46061c42 e011d104
400722c4 28006800 e02cd1e6 46294630 f00d4622
400722d4 1c43e926 d11e4607 f9c4f001 29046801

This is the first crash in 250 downloads, other than a Java one I sent myself for fun and was easy to diagnose. A similar post on stack overflow suggested the device was using an experimental form of Arti.

Apologies if the topic is wrong, I don’t know what to do?

So basically for games that crash on live, you want to use some kind of crash tracking service.

I think you can try using testin NDK to convert this memory address to actually readable stacks.

Check the accepted answer to this stackoverflow question.

While I haven’t developed an Android NDK app, it seems to me that’s it’s necessary to save the symbol files generated during the build in order to “symbolicate” (an Apple term) the crash dumps. Xcode automates this process for iOS apps, but for Android apps I’m guessing you’d have to manage that yourself. You need to be good with your version numbers too, else you will confuse yourself.

Thank you @trojanfoe. I’ve learned… “[NDK-STACK][1]”. It still looks much like a libc error, as indicated originally, now:

C:\Users\JB\HelloFooCln\HelloFoo\proj.android\obj>ndk-stack -sym C:\Users\JB\HelloFooCln\HelloFoo\proj.android\obj\local\armeabi -dump logdmp1.txt
********** Crash dump: **********
Build fingerprint: ‘lge/x5_spr_us/x5:4.4.2/KOT49I.LS740ZV5/LS740ZV5.1417913828:u
ser/release-keys’
pid: 21532, tid: 22073, name: Thread-2678 >>> uk.co.best_bit.pluckywords <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Stack frame #00 pc 000221d4 /system/lib/libc.so (tgkill+12)
Stack frame #01 pc 00013201 /system/lib/libc.so (pthread_kill+48)
Stack frame #02 pc 00013415 /system/lib/libc.so (raise+10)
Stack frame #03 pc 0001214b /system/lib/libc.so
Stack frame #04 pc 00021a88 /system/lib/libc.so (abort+4)
Stack frame #05 pc 0039cacf /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2
dcpp.so (__gnu_cxx::__verbose_terminate_handler()+230): Routine __gnu_cxx::__ver
bose_terminate_handler() at /s/ndk-toolchain/src/gcc/gcc-4.9/libstdc+±v3/libsup
c++/vterminate.cc:95

Maybe an issue with NDK 10d. Let me paste the other two reports here:

First I was able to locate the line, albeit from a much better back trace to begin with:

if (numInDB > useDB->getIntegerForKey("numRecs"))

********** Crash dump: **********
Build fingerprint: ‘lge/x5_spr_us/x5:4.4.2/KOT49I.LS740ZV5/LS740ZV5.1417913828:u
ser/release-keys’
pid: 31317, tid: 31336, name: Thread-2461 >>> uk.co.best_bit.pluckywords <<<
signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
Stack frame #00 pc 000221d4 /system/lib/libc.so (tgkill+12)
Stack frame #01 pc 00013201 /system/lib/libc.so (pthread_kill+48)
Stack frame #02 pc 00013415 /system/lib/libc.so (raise+10)
Stack frame #03 pc 0001214b /system/lib/libc.so
Stack frame #04 pc 00021a88 /system/lib/libc.so (abort+4)
Stack frame #05 pc 00048e03 /system/lib/libdvm.so (dvmAbort+78)
Stack frame #06 pc 0004d767 /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*,
jobject*)+146)
Stack frame #07 pc 0004e82b /system/lib/libdvm.so
Stack frame #08 pc 0011799f /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2
dcpp.so (cocos2d::JniHelper::getStaticMethodInfo(cocos2d::JniMethodInfo
&, char
const*, char const*, char const*)+98): Routine _JNIEnv::GetStaticMethodID(_jclas
s*, char const*, char const*) at C:/Android/android-ndk-r10d/platforms/android-1
4/arch-arm/usr/include/jni.h:760
Stack frame #09 pc 00117249 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2
dcpp.so (getIntegerForKeyJNI(char const*, int)+24): Routine getIntegerForKeyJNI(
char const*, int) at C:\Users\JB\HelloFooCln\HelloFoo\proj.android/jni/…/…/coc
os2d/cocos/platform/android/jni/Java_org_cocos2dx_lib_Cocos2dxHelper.cpp:258
Stack frame #10 pc 001716e9 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2
dcpp.so (cocos2d::UserDefault::getIntegerForKey(char const*, int)+82): Routine c
ocos2d::UserDefault::getIntegerForKey(char const*, int) at C:\Users\JB\HelloFooC
ln\HelloFoo\proj.android/jni/…/…/cocos2d/cocos/./base/CCUserDefault-android.cp
p:230
Stack frame #11 pc 001716f3 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2
dcpp.so (cocos2d::UserDefault::getIntegerForKey(char const*)+4): Routine cocos2d
::UserDefault::getIntegerForKey(char const*) at C:\Users\JB\HelloFooCln\HelloFoo
\proj.android/jni/…/…/cocos2d/cocos/./base/CCUserDefault-android.cpp:199
Stack frame #12 pc 00110c21 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2
dcpp.so (UserData::updateResultToPlayerDB(int, int, bool) const+56): Routine Use
rData::updateResultToPlayerDB(int, int, bool) const at C:\Users\JB\HelloFooCln\H
elloFoo\proj.android/jni/…/…/Classes/UserData.cpp:319

Which makes it look like the fault occurred in cocos2dx library code, v3.3, since I was calling with a string constant. It’s been a long time since I edited this code, believing it stable on all tests, so for verification here is the original backtrace, broadly similar enough to be considered equivalent:

backtrace:
#00 pc 000221d4 /system/lib/libc.so (tgkill+12)
#01 pc 00013201 /system/lib/libc.so (pthread_kill+48)
#02 pc 00013415 /system/lib/libc.so (raise+10)
#03 pc 0001214b /system/lib/libc.so
#04 pc 00021a88 /system/lib/libc.so (abort+4)
#05 pc 00048e03 /system/lib/libdvm.so (dvmAbort+78)
#06 pc 0004d767 /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*, jobject*)+146)
#07 pc 0004e82b /system/lib/libdvm.so
#08 pc 0011799f /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2dcpp.so (cocos2d::JniHelper::getStaticMethodInfo(cocos2d::JniMethodInfo
&, char const*, char const*, char const*)+98)
#09 pc 00117249 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2dcpp.so (getIntegerForKeyJNI(char const*, int)+24)
#10 pc 001716e9 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2dcpp.so (cocos2d::UserDefault::getIntegerForKey(char const*, int)+82)
#11 pc 001716f3 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2dcpp.so (cocos2d::UserDefault::getIntegerForKey(char const*)+4)
#12 pc 00110c21 /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2dcpp.so (UserData::updateResultToPlayerDB(int, int, bool) const+56)
#13 pc 0011352d /data/app-lib/uk.co.best_bit.pluckywords-1/libcocos2dcpp.so (MPResults::popUpVsScore(cocos2d::Node*, std::vector<std::string, std::allocatorstd::string >&, float, int, int)+428)

Finally, the 3rd trace, I’ll just summarise, the strstr libc call is crashing from the following:

static bool stringDescribesSPGame(const char *desc) {
    const char *eoi = strstr(desc, " on a");
    return (eoi - desc <= 13);
}```

To my inexpert eye this looks like incompatibility with NDK10d or libcocos v3.3 on certain devices. But that's more a guess really.


  [1]: http://discuss.cocos2d-x.org/t/how-to-use-ndk-stack-tool-to-debug-cocos2d-x-android-project/11701

OK chasing this line in the 2nd stack trace:

Stack frame #06 pc 0004d767 /system/lib/libdvm.so (dvmDecodeIndirectRef(Thread*,_jobject*)+146)

Led me to this stackoverflow question, which might help. In such situations you need to search for key elements of the stack trace to see if others have faced something similar. There is also this question (from this very forum), which is similar.

As far as the stringDescribesSPGame() method is concerned, you could probably be more defensive and avoid passing nullptr through to strstr(), which I’m fairly sure is the issue there:

static bool stringDescribesSPGame(const char *desc) {
    bool retval = false;
    if (desc && *desc) {
        const char *eoi = strstr(desc, " on a");
        retval = (eoi - desc <= 13);
    }
    return retval;
}