How to handle invalid pthread_t passed to libc?

1.5k views Asked by At

I'm using a library for connecting peripheral device with my Android app and I don't have any access to the library code. When I run my app on devices above Android 8, sometimes my app crashes with logs:

    2020-01-29 17:16:14.902 4811-5009/com.test.peripheral E/Device: session disconnect ret=-14 result:ERROR_PPCS_SESSION_CLOSED_CALLED
    2020-01-29 17:16:14.913 4811-5014/com.test.peripheral A/libc: invalid pthread_t 0x73cbb4c4f0 passed to libc
    2020-01-29 17:16:14.913 4811-5014/com.test.peripheral A/libc: Fatal signal 6 (SIGABRT), code -6 (SI_TKILL) in tid 5014 (Thread-32), pid 4811
    2020-01-29 17:16:14.934 4811-5015/com.test.peripheral A/libc: invalid pthread_t 0x73dc5ff4f0 passed to libc

I have already gone through this and other links related to libc crash: Android Oreo 8.0 Native C++ crash: invalid pthread_t passed to libc

Nowhere it's explained how to handle this issue in Android app. Since I don't have any access to the library code, I want to catch this exception in Android app and stop the app from crashing atleast. Can someone help with this issue?

1

There are 1 answers

0
vhamon On

It was already there before Oreo but it was handled differently.

It's explained in bionic's status.md : https://gerrit.pixelexperience.org/plugins/gitiles/bionic/+/HEAD/docs/status.md#invalid-handling-targetsdkversion-o

An improvement has been merged by Google's team some time ago to transform this "fatal" issue into a simple warning : https://android.googlesource.com/platform/bionic.git/+/5bb113cba279f93fb840954463e897b9e28a8660