SIGSEGV on Android (legacy mode)

Hello,

I get a segfault in an Android application. It used to work in January. The only source code changes I’ve made are removing references to the Sound class in my custom GameActivity.java. I didn’t manage to isolate the problem.

Here’s a stacktrace that I get on an x86 emulator with -Dlegacy and -debug. Any idea what’s going on?

The fun part is that this happens right after starting the app, and it still happens if I change my Main.new to {} :slight_smile: I found a __loadprim in Lib.hx in hxcpp, but I can’t figure out what’s going wrong (it apparently tries to throw an exception and crashes).

Thanks!

I/ActivityManager( 995): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=me.mbrezu.icebreaker/.MainActivity u=0} from pid 1119

D/dalvikvm( 995): GC_FOR_ALLOC freed 791K, 16% free 11261K/13383K, paused 6ms, total 9ms

I/ActivityManager( 995): Start proc me.mbrezu.icebreaker for activity me.mbrezu.icebreaker/.MainActivity: pid=1585 uid=10043 gids={3003, 1028}

E/Trace ( 1585): error opening trace file: No such file or directory (2)

I/dalvikvm( 1585): Could not find method android.view.View.getDisplay, referenced from method com.google.android.gms.internal.dw.b

W/dalvikvm( 1585): VFY: unable to resolve virtual method 1998: Landroid/view/View;.getDisplay ()Landroid/view/Display;

D/dalvikvm( 1585): VFY: replacing opcode 0x6e at 0x0009

W/PopupManager( 1585): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in future versions of the API. Use setViewForPopups() to set your content view.

D/dalvikvm( 1585): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libstd.so 0xb578ec10

D/dalvikvm( 1585): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libstd.so 0xb578ec10

D/dalvikvm( 1585): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libstd.so 0xb578ec10, skipping init

D/dalvikvm( 1585): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libregexp.so 0xb578ec10

D/dalvikvm( 1585): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libregexp.so 0xb578ec10

D/dalvikvm( 1585): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libregexp.so 0xb578ec10, skipping init

D/dalvikvm( 1585): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libzlib.so 0xb578ec10

D/dalvikvm( 1585): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libzlib.so 0xb578ec10

D/dalvikvm( 1585): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libzlib.so 0xb578ec10, skipping init

D/dalvikvm( 1585): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/liblime.so 0xb578ec10

I/OpenAL_SLES( 1585): alc_opensles_init

D/dalvikvm( 1585): Added shared lib /data/data/me.mbrezu.icebreaker/lib/liblime.so 0xb578ec10

D/dalvikvm( 1585): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so 0xb578ec10

D/dalvikvm( 1585): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so 0xb578ec10

D/dalvikvm( 1585): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so 0xb578ec10, skipping init

F/libc ( 1585): Fatal signal 11 (SIGSEGV) at 0xbb3beb0b (code=1), thread 1585 (rezu.icebreaker)

I/DEBUG ( 782): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***

I/DEBUG ( 782): Build fingerprint: ‘unknown’

I/DEBUG ( 782): pid: 1585, tid: 1585, name: UNKNOWN >>> me.mbrezu.icebreaker <<<

I/DEBUG ( 782): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr bb3beb0b

I/DEBUG ( 782): eax ad39e5e3 ebx ad3cf730 ecx 00000000 edx 0e01ffff

I/DEBUG ( 782): esi bb3beb0b edi ad3f1880

I/DEBUG ( 782): xcs 00000073 xds 0000007b xes 0000007b xfs 00000000 xss 0000007b

I/DEBUG ( 782): eip ad26effe ebp bfde9df8 esp bfde9db0 flags 00010203

I/DEBUG ( 782):

I/DEBUG ( 782): backtrace:

I/DEBUG ( 782): #00 pc 00413ffe /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (classify_object_over_fdes+283)

I/DEBUG ( 782): #01 pc 004142c1 /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (search_object+87)

I/DEBUG ( 782): #02 pc 004147e8 /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (_Unwind_Find_FDE+95)

I/DEBUG ( 782): #03 pc 0041303f /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (uw_frame_state_for+89)

I/DEBUG ( 782): #04 pc 0041335c /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (uw_init_context_1+68)

I/DEBUG ( 782): #05 pc 0041393f /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (_Unwind_RaiseException+50)

I/DEBUG ( 782): #06 pc 0040bea4 /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (__cxa_throw+100)

I/DEBUG ( 782): #07 pc 003cd271 /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (hx::NullArithmetic(char const*))

I/DEBUG ( 782): #08 pc 003c9aef /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (__loadprim(String, String, int)+566)

I/DEBUG ( 782): #09 pc 003959be /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (__boot_all()+1538)

I/DEBUG ( 782): #10 pc 00060408 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+232)

I/DEBUG ( 782): #11 pc 00049a51 /system/lib/libdvm.so (dvmCheckCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+65)

I/DEBUG ( 782): #12 pc 0006b51d /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const*, JValue*, Method const*, Thread*)+317)

I/DEBUG ( 782): #13 pc 000c53c8 /system/lib/libdvm.so

I/DEBUG ( 782): #14 pc 00028ff6 /system/lib/libdvm.so (dvmMterpStd(Thread*)+70)

I/DEBUG ( 782): #15 pc 000261c0 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+160)

I/DEBUG ( 782): #16 pc 00090ada /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+938)

I/DEBUG ( 782): #17 pc 000a1a5a /system/lib/libdvm.so (Dalvik_java_lang_reflect_Method_invokeNative(unsigned int const*, JValue*)+282)

I/DEBUG ( 782): #18 pc 000c53c8 /system/lib/libdvm.so

I/DEBUG ( 782): #19 pc 00028ff6 /system/lib/libdvm.so (dvmMterpStd(Thread*)+70)

I/DEBUG ( 782): #20 pc 000261c0 /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+160)

I/DEBUG ( 782): #21 pc 00091139 /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, char*)+601)

I/DEBUG ( 782): #22 pc 0006231a /system/lib/libdvm.so (CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+106)

I/DEBUG ( 782): #23 pc 000421f4 /system/lib/libdvm.so (Check_CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, char*)+436)

I/DEBUG ( 782): #24 pc 00051dba /system/lib/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, …)+42)

I/DEBUG ( 782): #25 pc 00053029 /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+969)

I/DEBUG ( 782): #26 pc 000011f7 /system/bin/app_process (main+599)

I/DEBUG ( 782): #27 pc 00016e7f /system/lib/libc.so (__libc_init+95)

I/DEBUG ( 782):

After updating my custom GameActivity.java class to include the changes in the legacy lime GameActivity.java, the stacktrace is now:

I/ActivityManager( 995): START {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=me.mbrezu.icebreaker/.MainActivity u=0
} from pid 1119
I/ActivityManager( 995): Start proc me.mbrezu.icebreaker for activity me.mbrezu.icebreaker/.MainActivity: pid=1904 uid=10043 gids={3003, 1028}
E/Trace ( 1904): error opening trace file: No such file or directory (2)
I/dalvikvm( 1904): Could not find method android.view.View.getDisplay, referenced from method com.google.android.gms.internal.dw.b
W/dalvikvm( 1904): VFY: unable to resolve virtual method 1999: Landroid/view/View;.getDisplay ()Landroid/view/Display;
D/dalvikvm( 1904): VFY: replacing opcode 0x6e at 0x0009
W/PopupManager( 1904): You have not specified a View to use as content view for popups. Falling back to the Activity content view which may not work properly in
future versions of the API. Use setViewForPopups() to set your content view.
D/dalvikvm( 1904): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libstd.so 0xb5795850
D/dalvikvm( 1904): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libstd.so 0xb5795850
D/dalvikvm( 1904): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libstd.so 0xb5795850, skipping init
D/dalvikvm( 1904): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libregexp.so 0xb5795850
D/dalvikvm( 1904): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libregexp.so 0xb5795850
D/dalvikvm( 1904): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libregexp.so 0xb5795850, skipping init
D/dalvikvm( 1904): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libzlib.so 0xb5795850
D/dalvikvm( 1904): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libzlib.so 0xb5795850
D/dalvikvm( 1904): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libzlib.so 0xb5795850, skipping init
D/dalvikvm( 1904): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/liblime-legacy.so 0xb5795850
I/OpenAL_SLES( 1904): alc_opensles_init
D/dalvikvm( 1904): Added shared lib /data/data/me.mbrezu.icebreaker/lib/liblime-legacy.so 0xb5795850
D/dalvikvm( 1904): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so 0xb5795850
D/dalvikvm( 1904): Added shared lib /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so 0xb5795850
D/dalvikvm( 1904): No JNI_OnLoad found in /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so 0xb5795850, skipping init
I/haxe plugin( 1904): Got Load Proc ad2ef115
I/haxe plugin( 1904): Got Load Proc ad2ef115
I/haxe plugin( 1904): Got Load Proc ad2ef115
I/CreateMainFrame!( 1904): creating…
D/libEGL ( 1904): loaded /system/lib/egl/libEGL_emulation.so
D/ ( 1904): HostConnection::get() New Host Connection established 0xb8b07630, tid 1904
D/libEGL ( 1904): loaded /system/lib/egl/libGLESv1_CM_emulation.so
D/libEGL ( 1904): loaded /system/lib/egl/libGLESv2_emulation.so
E/dalvikvm( 1904): Could not find class ‘com.flurry.sdk.i’, referenced from method com.flurry.sdk.ho.a
W/dalvikvm( 1904): VFY: unable to resolve const-class 516 (Lcom/flurry/sdk/i;) in Lcom/flurry/sdk/ho;
D/dalvikvm( 1904): VFY: replacing opcode 0x1c at 0x001e
W/GooglePlayServicesUtil( 1904): Google Play Store is missing.
W/FlurryAgent( 1904): Google Play Services not available - connection result: 9
I/dalvikvm( 1904): Could not find method android.os.StatFs.getAvailableBlocksLong, referenced from method com.flurry.sdk.ez.a
W/dalvikvm( 1904): VFY: unable to resolve virtual method 321: Landroid/os/StatFs;.getAvailableBlocksLong ()J
D/dalvikvm( 1904): VFY: replacing opcode 0x6e at 0x003c
W/FlurryAgent( 1904): Flurry session created for context:[email protected]
W/FlurryAgent( 1904): Flurry session started for context:[email protected]
D/dalvikvm( 995): WAIT_FOR_CONCURRENT_GC blocked 0ms
W/GooglePlayServicesUtil( 1904): Google Play Store is missing.
W/GooglePlayServicesUtil( 1904): Google Play Store is missing.
D/dalvikvm( 1904): Trying to load lib /data/data/me.mbrezu.icebreaker/lib/liblime-legacy.so 0xb5795850
D/dalvikvm( 1904): Shared lib ‘/data/data/me.mbrezu.icebreaker/lib/liblime-legacy.so’ already loaded in same CL 0xb5795850
D/dalvikvm( 995): GC_EXPLICIT freed 259K, 16% free 11517K/13703K, paused 2ms+1ms, total 23ms
D/dalvikvm( 1904): GC_CONCURRENT freed 211K, 3% free 8143K/8391K, paused 13ms+0ms, total 16ms
W/GameHelper( 1904): disconnect() called when client was already disconnected.
E/GooglePlayServicesUtil( 1904): Google Play services is invalid. Cannot recover.
W/EGL_emulation( 1904): eglSurfaceAttrib not implemented
D/OpenGLRenderer( 1904): Enabling debug mode 0
D/ ( 1904): HostConnection::get() New Host Connection established 0xb8b3a688, tid 1918
V/VIEW ( 1904): onSurfaceCreated
V/VIEW ( 1904): Thread = 102
V/VIEW ( 1904): onSurfaceChanged 480,800
V/VIEW ( 1904): Thread = 102
W/System.err( 1904): java.lang.NoClassDefFoundError: org/haxe/extension/Extension
W/System.err( 1904): at org.haxe.lime.Lime.onResize(Native Method)
W/System.err( 1904): at org.haxe.lime.MainView$Renderer.onSurfaceChanged(Unknown Source)
W/System.err( 1904): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
W/System.err( 1904): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
W/System.err( 1904): Caused by: java.lang.ClassNotFoundException: org.haxe.extension.Extension
W/System.err( 1904): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
W/System.err( 1904): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/System.err( 1904): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
W/System.err( 1904): … 4 more
F/libc ( 1904): Fatal signal 11 (SIGSEGV) at 0xbb4b8da7 (code=1), thread 1918 (Thread-102)
W/EGL_emulation( 1904): eglSurfaceAttrib not implemented
I/DEBUG ( 782): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
I/DEBUG ( 782): Build fingerprint: 'unknown’
I/DEBUG ( 782): pid: 1904, tid: 1918, name: UNKNOWN >>> me.mbrezu.icebreaker <<<
I/DEBUG ( 782): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr bb4b8da7
I/DEBUG ( 782): eax ad49887f ebx ad4c9730 ecx 00000000 edx 0e01ffff
I/DEBUG ( 782): esi bb4b8da7 edi ad4db440
I/DEBUG ( 782): xcs 00000073 xds 0000007b xes 0000007b xfs 00000000 xss 0000007b
I/DEBUG ( 782): eip ad369cbe ebp ac8a1b08 esp ac8a1ac0 flags 00010203
I/DEBUG ( 782):
I/DEBUG ( 782): backtrace:
I/DEBUG ( 782): #00 pc 00411cbe /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (classify_object_over_fdes+283)
I/DEBUG ( 782): #01 pc 00411f81 /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (search_object+87)
I/DEBUG ( 782): #02 pc 004124a8 /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (_Unwind_Find_FDE+95)
I/DEBUG ( 782): #03 pc 00410cff /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (uw_frame_state_for+89)
I/DEBUG ( 782): #04 pc 0041101c /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (uw_init_context_1+68)
I/DEBUG ( 782): #05 pc 004115ff /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (_Unwind_RaiseException+50)
I/DEBUG ( 782): #06 pc 00409b64 /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (__cxa_throw+100)
I/DEBUG ( 782): #07 pc 003caf2d /data/data/me.mbrezu.icebreaker/lib/libApplicationMain.so (hx::NullArithmetic(char const*))
I/DEBUG ( 782): #08 pc 0009c7b0 /data/data/me.mbrezu.icebreaker/lib/liblime-legacy.so
I/DEBUG ( 782):

You can sometimes get more information by compiling with these flags:

<haxedef name="HXCPP_CHECK_POINTER" />
<haxedef name="HXCPP_STACK_LINE" />

Could you try doing a clean build of a simple sample, like “DisplayingABitmap”, and see if that works for you?

If you are not using the same Java classes, make sure it loads “lime-legacy” and not “lime”

Hello again,

turns out it wasn’t my different Java classes, but Proguard :smile:

Let me show again a bit of the stacktrace:

W/System.err( 1904): java.lang.NoClassDefFoundError: org/haxe/extension/Extension
W/System.err( 1904): at org.haxe.lime.Lime.onResize(Native Method)
W/System.err( 1904): at org.haxe.lime.MainView$Renderer.onSurfaceChanged(Unknown Source)
W/System.err( 1904): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1505)
W/System.err( 1904): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)
W/System.err( 1904): Caused by: java.lang.ClassNotFoundException: org.haxe.extension.Extension
W/System.err( 1904): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
W/System.err( 1904): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
W/System.err( 1904): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)

Worth checking out, right? After disabling Proguard in project.properties my app worked. After a couple rounds of Proguard whacamole I added this to my proguard config:

-keep class org.haxe.extension.Extension { *; }

Now everything works.

I guess a bit of error handling should be added when trying to get/use the Extension class. And for everybody else out there debugging a startup crash, try disabling Proguard :smile:

Thanks!

1 Like

Wow, interesting. Is there something we could to improve the default Android template to avoid this?

Maybe the C++ code that tries to get/use Extension should do more error checking and maybe fail more gracefully? I’m just guessing here, my JNI-fu is pretty much non-existent and my knowledge of OpenFL extensions is completely non-existent, so I can’t tell how ‘graceful failure’ looks like because I don’t know the use cases.

Are you using any extensions?

The only code I can find that references by name is from the extension project sample:

	#if (android && openfl)
	private static var ::extensionLowerCase::_sample_method_jni = JNI.createStaticMethod ("org.haxe.extension.::className::", "sampleMethod", "(I)I");
	#end

Not intentionally :smile:

How can I tell?

I have this line in project.properties:

android.library.reference.1=deps/extension-api

But I’m not sure why (my guess is this was in the project.properties in the template when I made my copy for customization).

Thanks!

Complete project.properties:

# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
# 
# This file must be checked in Version Control Systems.
# 
# To customize properties used by the Ant build system use,
# "build.properties", and override values to adapt the script to your
# project structure.

manifestmerger.enabled=true

android.library.reference.1=deps/extension-api
android.library.reference.2=deps/google-play-services

# Project target.
target=android-16

key.store=<removed>
key.alias=<removed>
key.store.password=<removed>
key.alias.password=<removed>

proguard.config=proguard-config.txt

OK, so if I remove the deps/extension-api line the GameActivity.java file fails to compile (the stock parts, not my changes). So the line is not useless, even though I don’t use any extensions.