Android 7 Native Crash: libc.so tgkill

AlexVPerl picture AlexVPerl · May 20, 2017 · Viewed 31.5k times · Source

I'm seeing this native crash with the following stack trace.

This happens in Android 7.0 & 7.1 only. Nothing new has been added to the app, which has been in production for a few years, but with more devices being updated to Nougat this crash happens frequently now and is becoming a nuisance.

Any advice would be appreciated.

native: pc 000000000007a6c4  /system/lib64/libc.so (tgkill+8)
  native: pc 0000000000077920  /system/lib64/libc.so (pthread_kill+64)
  native: pc 000000000002538c  /system/lib64/libc.so (raise+24)
  native: pc 000000000001d24c  /system/lib64/libc.so (abort+52)
  native: pc 000000000001225c  /system/lib64/libcutils.so (__android_log_assert+224)
  native: pc 00000000000610e0  /system/lib64/libhwui.so
  native: pc 000000000003908c  /system/lib64/libhwui.so
  native: pc 000000000003609c  /system/lib64/libhwui.so
  native: pc 000000000003b4fc  /system/lib64/libhwui.so
  native: pc 000000000003c520  /system/lib64/libhwui.so
  native: pc 000000000003e694  /system/lib64/libhwui.so (_ZN7android10uirenderer12renderthread12RenderThread10threadLoopEv+152)
  native: pc 00000000000127f0  /system/lib64/libutils.so (_ZN7android6Thread11_threadLoopEPv+336)
  native: pc 00000000000a50b0  /system/lib64/libandroid_runtime.so (_ZN7android14AndroidRuntime15javaThreadShellEPv+116)
  native: pc 00000000000770f4  /system/lib64/libc.so (_ZL15__pthread_startPv+204)
  native: pc 000000000001e7d0  /system/lib64/libc.so (__start_thread+16)

Here's a list of devices that are affected: enter image description here

UPDATE 7/18:

Still unable to get to the root of this, so I decided to purchase a device which had most occurrences and was reasonably priced, which turned out to be Samsung Galaxy J3 2017 version with Android 7.0. Unfortunately I am still unable to reproduce the crash.

I've also made some memory usage improvements to the app in production, but the crash is still happening.

From all the comments and my own research it seems to be related to dynamically linked NDKs, but I'm not using any and its hard to find out if any of the dependencies do.

I would like to share my dependencies, it would be great if other folks facing the same issue could call out if they are using one of the same dependencies - perhaps we can spot the culprit this way.

// App Compat
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.android.support:appcompat-v7:23.0.1'
    compile 'com.android.support:cardview-v7:23.0.1'
    compile 'com.android.support:recyclerview-v7:23.0.1'

    // Play Services
    compile 'com.google.android.gms:play-services-location:8.3.0'
    compile 'com.google.android.gms:play-services-maps:8.3.0'
    compile 'com.google.android.gms:play-services-analytics:8.3.0'
    compile 'com.google.android.gms:play-services-appindexing:8.3.0'
    compile 'com.google.android.gms:play-services-ads:8.3.0'

    // Misc Libraries
    compile 'fr.avianey.com.viewpagerindicator:library:2.4.1@aar'
    compile files('app/libs/htmlcleaner-2.7.jar')
    compile files('app/libs/protobuf-java-2.6.0.jar')
    compile files('app/libs/nineoldandroids-2.4.0.jar')

    // Fabric
    compile('com.twitter.sdk.android:twitter:1.13.0@aar') { transitive = true; }
    compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { transitive = true; }

For folks facing the same crash, please respond in comments if you are using any of these dependencies / versions. Maybe we can single out the problem dependency.

Answer

Lennart Rolland picture Lennart Rolland · Jun 11, 2017

Looking at the dump you provided gives some clues:

_ZN7android10uirenderer12renderthread12RenderThread10threadLoopEv

This indicates that the error occurred in the UI thread.

libhwui.so x 6

This indicates that this is happening in the middle of some graphics/ui related code.

libcutils.so - __android_log_assert

This is an assert handler, so most likely some kind of assert was violated in libwhui.

abort:

This is the application telling the O/S to shut down "abnormally".

raise + pthread_kill + tgkill: This is the O/S (Android) shutting down the app.

You can see some documentation for debugging these kinds of crashes here.

Anyway, I am afraid it is really difficult to speculate beyond this coarse and imprecise interpretation of the data you presented.

Maybe if you caught the bug while it was attached to the Android log viewer, you would have more application specific data (or even an error message which the assert function usually puts out).

My tip is to use something like ACRA to track down all the details pertaining to the error, or get hold of an affected device and actually reproduce it while attached to a debugger.

Good luck!

EDIT 2017-06-16: I just want to add some extra info courtesy comment by Fco P. Apparently Google has decided to make some changes to what native libraries are allowed to run in latest versions of Android (7.x). More details are in this link.