Android Oreo 8.0 Native C ++崩溃:无效的pthread_t传递给libc [英] Android Oreo 8.0 Native C++ crash: invalid pthread_t passed to libc
问题描述
我有一个使用Cmake将本机代码编译到我的应用程序中的Android应用程序,它在运行Android 7.1的Pixel设备上运行良好.我决定将我的Pixel设备升级到Oreo 8.0,现在我无法在我的应用程序中输入本机C ++代码.
I have an Android Application that uses Cmake to compile native code into my application, and it was working great on A Pixel device running Android 7.1. I decided to upgrade my Pixel device to Oreo 8.0 and now I cannot enter the native C++ code in my app.
这是崩溃时的logcat转储:
This is the logcat dump when it crashes:
A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
A/DEBUG: Build fingerprint: 'google/sailfish/sailfish:8.0.0/OPR3.170623.007/4286350:user/release-keys'
A/DEBUG: Revision: '0'
A/DEBUG: ABI: 'arm64'
A/DEBUG: pid: 29454, tid: 30950, name: Thread-24 >>> com.myapp.nativecppapp <<<
A/DEBUG: signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
A/DEBUG: Abort message: 'invalid pthread_t 0x727d3004f0 passed to libc'
A/DEBUG: x0 0000000000000000 x1 00000000000078e6 x2 0000000000000006 x3 0000000000000008
A/DEBUG: x4 0000000000000000 x5 0000000000000000 x6 0000000000000000 x7 0000000000000030
A/DEBUG: x8 0000000000000083 x9 222b2e8c5b032e6a x10 0000000000000000 x11 0000000000000001
A/DEBUG: x12 ffffffffffffffff x13 0000000000000001 x14 0000000000000000 x15 000849a75d18b53a
A/DEBUG: x16 00000072a8aee2f8 x17 00000072a8a905d0 x18 00000072a70fef30 x19 000000000000730e
A/DEBUG: x20 00000000000078e6 x21 0000007286081ac0 x22 000000728609b998 x23 0000007286081a88
A/DEBUG: x24 0000007286081ac4 x25 000000727d3fcee0 x26 000000727d3fceb8 x27 00000000000001cc
A/DEBUG: x28 000000727fe6b000 x29 000000727d3fcc20 x30 00000072a8a44994
A/DEBUG: sp 000000727d3fcbe0 pc 00000072a8a905d8 pstate 0000000060000000
A/DEBUG: backtrace:
A/DEBUG: #00 pc 00000000000695d8 /system/lib64/libc.so (tgkill+8)
A/DEBUG: #01 pc 000000000001d990 /system/lib64/libc.so (abort+88)
A/DEBUG: #02 pc 000000000002516c /system/lib64/libc.so (__libc_fatal+116)
A/DEBUG: #03 pc 0000000000066470 /system/lib64/libc.so (_Z23__pthread_internal_findl+164)
A/DEBUG: #04 pc 0000000000065fa8 /system/lib64/libc.so (pthread_detach+16)
A/DEBUG: #05 pc 0000000000043528 /data/app/com.myapp.nativecppapp-SwBY2G1qycu-8Vec8QIe8w==/lib/arm64/libNativeLib.so
A/DEBUG: #06 pc 000000000002a6e4 /data/app/com.myapp.nativecppapp-SwBY2G1qycu-8Vec8QIe8w==/lib/arm64/libNativeLib.so
A/DEBUG: #07 pc 0000000000052430 /data/app/com.myapp.nativecppapp-SwBY2G1qycu-8Vec8QIe8w==/lib/arm64/libNativeLib.so
A/DEBUG: #08 pc 000000000005176c /data/app/com.myapp.nativecppapp-SwBY2G1qycu-8Vec8QIe8w==/lib/arm64/libNativeLib.so
A/DEBUG: #09 pc 000000000004339c /data/app/com.myapp.nativecppapp-SwBY2G1qycu-8Vec8QIe8w==/lib/arm64/libNativeLib.so
A/DEBUG: #10 pc 0000000000065f88 /system/lib64/libc.so (_ZL15__pthread_startPv+36)
A/DEBUG: #11 pc 000000000001ed24 /system/lib64/libc.so (__start_thread+68)
这是添加共享库的Cmake代码
Here is the Cmake code that adds the shared library
add_library(NativeLib SHARED IMPORTED)
set_property(TARGET NativeLib PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/NativeLib/Android/Release/${ANDROID_ABI}/libNativeLib.so")
共享库然后链接到目标.
The shared library then gets linked to the target.
正如我所说,这一切都在Android 7.1上完美运行,并将设备升级到8.0导致了崩溃,这是一个新的错误吗?我确实在这里 https:上阅读了8.0的本地库"更改.//developer.android.com/about/versions/oreo/android-8.0-changes.html .
As I said, this was all running flawlessly on Android 7.1 and upgrading the device to 8.0 caused this crash, is this a new bug? I did read the "Native Libraries" changes for 8.0 here https://developer.android.com/about/versions/oreo/android-8.0-changes.html.
我还在我的图书馆上运行了readelf并把它取回来,这对于8.0来说还可以:
I also ran readelf on my library and got this back, which looks okay for 8.0:
LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x1b61c8 0x1b61c8 R E 0x10000
LOAD 0x1b6750 0x00000000001c6750 0x00000000001c6750 0x015fc0 0x085260 RW 0x10000
DYNAMIC 0x1c1010 0x00000000001d1010 0x00000000001d1010 0x0002c0 0x0002c0 RW 0x8
GNU_EH_FRAME 0x1871a0 0x00000000001871a0 0x00000000001871a0 0x006bac 0x006bac R 0x4
GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x10
GNU_RELRO 0x1b6750 0x00000000001c6750 0x00000000001c6750 0x00b8b0 0x00b8b0 R 0x1
有什么想法吗?谢谢!
推荐答案
问题出在 __ pthread_internal_find 函数中.
在Android 8.0之前,如果在线程列表中找不到线程,则仅返回nullptr.但是,在Android 8.0中,将会发生致命事故.
Before Android 8.0, if no thread can be found in the thread list, just a nullptr is returned. However, in Android 8.0, a fatal will be made.
无论如何,这需要更仔细地处理POSIX内容...
This is requiring more careful handling of the POSIX stuff anyway...
请参见 pthread_internal.cpp 供参考.
这篇关于Android Oreo 8.0 Native C ++崩溃:无效的pthread_t传递给libc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!