You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When compiling our app with libc++ runtime and clang, as soon as first native method is called, we get a SIGSEGV with invalid stack trace (stack trace points to file and line number which can be reached only from completely different JNI method).
When using libc++ + GCC, app crashes when attempting to throw c++ exception.
GNU STL + clang and GNU STL + GCC combinations work correctly. We've tested on Samsung Galaxy Ace: armeabi ABI + Android 2.3 (API level 10).
E/AndroidRuntime( 5460): FATAL EXCEPTION: main
E/AndroidRuntime( 5460): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 5460): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 5460): at java.lang.Class.newInstance(Class.java:1409)
E/AndroidRuntime( 5460): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 5460): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
E/AndroidRuntime( 5460): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 5460): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 5460): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 5460): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5460): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 5460): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 5460): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5460): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 5460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 5460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 5460): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5460): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1479]: 67 unknown reloc type 160 @ ( 379)
E/AndroidRuntime( 5460): at java.lang.Runtime.loadLibrary(Runtime.java:434)
E/AndroidRuntime( 5460): at java.lang.System.loadLibrary(System.java:554)
E/AndroidRuntime( 5460): at com.example.hellojni.HelloJni.(HelloJni.java:64)
E/AndroidRuntime( 5460): ... 15 more
W/ActivityManager( 106): Force finishing activity com.example.hellojni/.HelloJni
Relocation 160 is an ifunc. After some readelf and some objdump, tracked that down to libatomic. Android doesn't support ifuncs until M, so this is going to require a fix to GCC...
A little more testing shows that this is specific to GCC, which is why the libc++ test suite didn't catch it (we don't run the tests with GCC yet because our version of libc++ is far too old for the test suite to be very GCC compatible).
Just as an FYI, not clear if this will be in the r12 beta that I'll be kicking out in a couple weeks, but it will definitely be in the r12 release in June.
@DanAlbert, we didn't experience that crash on Android 4.0, 4.1 and 4.4 - only on 2.3. Are you sure this affects all android versions up until 5.0?
EDIT: sorry, I didn't notice that this is solely an armeabi issue (i.e. not present in armeabi-v7a and x86, which we used for testing on 4.0, 4.1 and 4.4).
Activity
DanAlbert commentedon Mar 21, 2016
Most likely this is a dup of http://b.android.com/181517. I assume this was
libc++_shared?DoDoENT commentedon Mar 21, 2016
@DanAlbert I cannot open your link. It was
libc++_static.Edit: http version of link works for me.
DanAlbert commentedon Mar 21, 2016
Oops. Link fixed, but I guess not then...
DoDoENT commentedon Mar 21, 2016
Well, the libc++ + clang version crashed with SIGSEGV immediately when calling native method and stack trace was completely wrong.
Hopefully I will have time to investigate this further next week and probably prepare some sample.
DanAlbert commentedon Mar 22, 2016
E/AndroidRuntime( 5460): FATAL EXCEPTION: main
E/AndroidRuntime( 5460): java.lang.ExceptionInInitializerError
E/AndroidRuntime( 5460): at java.lang.Class.newInstanceImpl(Native Method)
E/AndroidRuntime( 5460): at java.lang.Class.newInstance(Class.java:1409)
E/AndroidRuntime( 5460): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
E/AndroidRuntime( 5460): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1561)
E/AndroidRuntime( 5460): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime( 5460): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime( 5460): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime( 5460): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 5460): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 5460): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 5460): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 5460): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 5460): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 5460): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 5460): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 5460): Caused by: java.lang.UnsatisfiedLinkError: Cannot load library: reloc_library[1479]: 67 unknown reloc type 160 @ ( 379)
E/AndroidRuntime( 5460): at java.lang.Runtime.loadLibrary(Runtime.java:434)
E/AndroidRuntime( 5460): at java.lang.System.loadLibrary(System.java:554)
E/AndroidRuntime( 5460): at com.example.hellojni.HelloJni.(HelloJni.java:64)
E/AndroidRuntime( 5460): ... 15 more
W/ActivityManager( 106): Force finishing activity com.example.hellojni/.HelloJni
Relocation 160 is an ifunc. After some readelf and some objdump, tracked that down to libatomic. Android doesn't support ifuncs until M, so this is going to require a fix to GCC...
DanAlbert commentedon Mar 22, 2016
A little more testing shows that this is specific to GCC, which is why the libc++ test suite didn't catch it (we don't run the tests with GCC yet because our version of libc++ is far too old for the test suite to be very GCC compatible).
cjhopman commentedon Apr 4, 2016
Maybe the title should be updated, this is much worse than the title implies:
The failure isn't limited to libc++ runtime, and it affects android up until 5.0 (not just the rather old 2.3).
Would it be possible to recompile libatomic with HAVE_IFUNC=false? After a cursory look it appears to support that.
[-]LibC++ runtime does not work on Android 2.3[/-][+]armeabi libatomic.a uses ifuncs[/+]DanAlbert commentedon Apr 4, 2016
Yeah, the fix is nearly done. The changes to our GCC were https://android-review.googlesource.com/#/c/210660/ and https://android-review.googlesource.com/#/c/212250/. I just need to actually pull the new prebuilts into the NDK.
Updated the title to reflect the issue more clearly.
DanAlbert commentedon Apr 4, 2016
Just as an FYI, not clear if this will be in the r12 beta that I'll be kicking out in a couple weeks, but it will definitely be in the r12 release in June.
DoDoENT commentedon Apr 5, 2016
@DanAlbert, we didn't experience that crash on Android 4.0, 4.1 and 4.4 - only on 2.3. Are you sure this affects all android versions up until 5.0?
EDIT: sorry, I didn't notice that this is solely an armeabi issue (i.e. not present in armeabi-v7a and x86, which we used for testing on 4.0, 4.1 and 4.4).
DanAlbert commentedon Apr 7, 2016
Fix is in for r12.
Add a test for libatomic using ifuncs.
Mark tests as passing following toolchain updates.
[core] Revert workaround for std::atomic on ARMv5