How to debug Native crash in libcorona.so

My new CoronaCards-based Android app is doing well and seems to be well-received in the Google Play store, but I’m seeing these crashes in the wild and don’t know how to debug them because they are happening in libcorona.so.  Here is the crash log as reported in the Google Play dev console.  It’s a lot of jibberish, but the part that might be interpretable is:

(Java_com_ansca_corona_JavaToNativeShim_nativeDone+28)

Any ideas or tips on how to debug this?  Unfortunately I’m seeing quite a bit of these and getting some 1-star reviews as a result.

Thanks,

Alex

Build fingerprint: ‘Verizon/jfltevzw/jfltevzw:4.4.2/KOT49H/I545VRUFNK1:user/release-keys’
Revision: ‘11’
pid: 8819, tid: 8819, name: emedia.launcher >>> com.bonfiremedia.launcher <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000000
r0 00000000 r1 b6e00019 r2 72780a98 r3 00000000
r4 72780a98 r5 416c2978 r6 00000000 r7 6d66ac54
r8 beda7330 r9 6d66ac4c sl 416c3d68 fp beda7344
ip 76d02320 sp beda7310 lr 76cff44c pc 76d03c14 cpsr 800b0010
d0 63736e612f6d6f63 d1 616e6f726f632f61
d2 4e6f546176614a2f d3 6968536576697461
d4 0000000040f11111 d5 457c000044070000
d6 3e4ccccd00be5c00 d7 42c800004bc9f7d0
d8 0000000000000000 d9 0000000000000000
d10 0000000000000000 d11 0000000000000000
d12 0000000000000000 d13 0000000000000000
d14 0000000000000000 d15 0000000000000000
d16 6e5f6d6968536576 d17 6e6f446576697461
d18 002e00640069006f d19 00610063006f006c
d20 006e006f00690074 d21 006f004c0049002e
d22 0069007400610063 d23 0061004d006e006f
d24 0000000000000000 d25 0000000000000000
d26 3f41111120000000 d27 bf41111120000000
d28 0000000000000000 d29 0000000000000000
d30 ffd8bc7effd8bc7e d31 f2c6a457f2c6a457
scr 28000012

backtrace:
#00 pc 00034c14 /data/app-lib/com.bonfiremedia.launcher-1/libcorona.so
#01 pc 00030448 /data/app-lib/com.bonfiremedia.launcher-1/libcorona.so
#02 pc 0003333c /data/app-lib/com.bonfiremedia.launcher-1/libcorona.so (Java_com_ansca_corona_JavaToNativeShim_nativeDone+28)
#03 pc 00020d4c /system/lib/libdvm.so (dvmPlatformInvoke+112)
#04 pc 000519ef /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+398)
#05 pc 000533d1 /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+184)
#06 pc 0002a1e0 /system/lib/libdvm.so
#07 pc 00031690 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#08 pc 0002ed28 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#09 pc 00064139 /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+392)
#10 pc 0006c4f3 /system/lib/libdvm.so
#11 pc 0002a1e0 /system/lib/libdvm.so
#12 pc 00031690 /system/lib/libdvm.so (dvmMterpStd(Thread*)+76)
#13 pc 0002ed28 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+184)
#14 pc 00063e55 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+336)
#15 pc 0004d5d7 /system/lib/libdvm.so
#16 pc 000522ff /system/lib/libandroid_runtime.so
#17 pc 00053893 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+354)
#18 pc 0000105b /system/bin/app_process
#19 pc 0000e4f3 /system/lib/libc.so (__libc_init+50)
#20 pc 00000d7c /system/bin/app_process

The crash log in my previous post was from Google Play dev console.

Here’s a crash log from Flurry that seems to be more readable, though I’m not 100% sure it’s referring to the same crash.

Full Stack Trace:com.naef.jnlua.LuaRuntimeException

com.naef.jnlua.LuaState.lua_pcall(Native Method)

com.naef.jnlua.LuaState.call(Unknown Source)

com.ansca.corona.CoronaLua.dispatchRuntimeEvent(CoronaLua.java:293)

com.ansca.corona.CoronaView$2.executeUsing(CoronaView.java:236)

com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)

com.ansca.corona.events.EventManager.sendEvents(EventManager.java:87)

com.ansca.corona.Controller.updateRuntimeState(Controller.java:281)

com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)

com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)

com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

Looks like its happening when Lua is trying to dispatch an event to Java.  You might want to look around points where you’re communicating between the two and see if you can spot a condition where you might be passing unexpected data.

Rob

Thanks Rob.

But actually, through some investigation I found that the stack trace I’m getting above happens when there’s a runtime exception in my Lua code, because I found the same exact stack trace in logcat, but with the top line as something like:

com.naef.jnlua.LuaRuntimeException: icon_utils:36: bad argument #1 to ‘ipairs’ (table expected, got nil)

So, the good news is that I think I at least know it’s probably a Lua runtime bug in my code; the bad news is that Flurry’s crash reporting doesn’t spit out the line # of the Lua code that is causing the LuaRuntimeException, even though it does appear in logcat.

Anybody have any idea how to get Flurry’s stack trace to spit out the Lua line # the same way logcat does?  These errors I’m getting are happening in the wild, and I don’t know how to reproduce them.  

I’m going try using Fabric.io to see if I can get better stack traces.

Hi,

Just downloaded your app from the play store and while trying to run it on a Nexus 7(2013) model, on Android 5.0 I get the following error:

12-15 09:28:14.573: I/Corona(13576): Runtime error

12-15 09:28:14.573: I/Corona(13576): icon_folder:15: attempt to perform arithmetic on field ‘icon_folderSizeGrid’ (a nil value)

12-15 09:28:14.573: I/Corona(13576): stack traceback:

12-15 09:28:14.573: I/Corona(13576): icon_folder:15: in main chunk

12-15 09:28:14.573: I/Corona(13576): [C]: in function ‘require’

12-15 09:28:14.573: I/Corona(13576): /Users/jenkins/slaveroot/workspace/CoronaCards/OS/android/platform/resources/init.lua:820: in function ‘require’

12-15 09:28:14.573: I/Corona(13576): /data/data/com.bonfiremedia.launcher/files/coronaResources/icongrid/main.lua:17: in main chunk

All I do is start your launcher.

This might be related to the errors you’re seeing.

Thanks Danny! Yes, we forgot to regression test version 2.13 of our launcher on tablets, and on tablets, we had that stupid error.  We are releasing 2.14 right now which fixes that issue. 

Will be interesting to see how many of those stack traces we get after this.  I also implemented Fabric.io so that might help too.

The crash log in my previous post was from Google Play dev console.

Here’s a crash log from Flurry that seems to be more readable, though I’m not 100% sure it’s referring to the same crash.

Full Stack Trace:com.naef.jnlua.LuaRuntimeException

com.naef.jnlua.LuaState.lua_pcall(Native Method)

com.naef.jnlua.LuaState.call(Unknown Source)

com.ansca.corona.CoronaLua.dispatchRuntimeEvent(CoronaLua.java:293)

com.ansca.corona.CoronaView$2.executeUsing(CoronaView.java:236)

com.ansca.corona.CoronaRuntimeTaskDispatcher$TaskEvent.Send(CoronaRuntimeTaskDispatcher.java:148)

com.ansca.corona.events.EventManager.sendEvents(EventManager.java:87)

com.ansca.corona.Controller.updateRuntimeState(Controller.java:281)

com.ansca.corona.graphics.opengl.CoronaGLSurfaceView$CoronaRenderer.onDrawFrame(CoronaGLSurfaceView.java:417)

com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1622)

com.ansca.corona.graphics.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1377)

Looks like its happening when Lua is trying to dispatch an event to Java.  You might want to look around points where you’re communicating between the two and see if you can spot a condition where you might be passing unexpected data.

Rob

Thanks Rob.

But actually, through some investigation I found that the stack trace I’m getting above happens when there’s a runtime exception in my Lua code, because I found the same exact stack trace in logcat, but with the top line as something like:

com.naef.jnlua.LuaRuntimeException: icon_utils:36: bad argument #1 to ‘ipairs’ (table expected, got nil)

So, the good news is that I think I at least know it’s probably a Lua runtime bug in my code; the bad news is that Flurry’s crash reporting doesn’t spit out the line # of the Lua code that is causing the LuaRuntimeException, even though it does appear in logcat.

Anybody have any idea how to get Flurry’s stack trace to spit out the Lua line # the same way logcat does?  These errors I’m getting are happening in the wild, and I don’t know how to reproduce them.  

I’m going try using Fabric.io to see if I can get better stack traces.

Hi,

Just downloaded your app from the play store and while trying to run it on a Nexus 7(2013) model, on Android 5.0 I get the following error:

12-15 09:28:14.573: I/Corona(13576): Runtime error

12-15 09:28:14.573: I/Corona(13576): icon_folder:15: attempt to perform arithmetic on field ‘icon_folderSizeGrid’ (a nil value)

12-15 09:28:14.573: I/Corona(13576): stack traceback:

12-15 09:28:14.573: I/Corona(13576): icon_folder:15: in main chunk

12-15 09:28:14.573: I/Corona(13576): [C]: in function ‘require’

12-15 09:28:14.573: I/Corona(13576): /Users/jenkins/slaveroot/workspace/CoronaCards/OS/android/platform/resources/init.lua:820: in function ‘require’

12-15 09:28:14.573: I/Corona(13576): /data/data/com.bonfiremedia.launcher/files/coronaResources/icongrid/main.lua:17: in main chunk

All I do is start your launcher.

This might be related to the errors you’re seeing.

Thanks Danny! Yes, we forgot to regression test version 2.13 of our launcher on tablets, and on tablets, we had that stupid error.  We are releasing 2.14 right now which fixes that issue. 

Will be interesting to see how many of those stack traces we get after this.  I also implemented Fabric.io so that might help too.