gpt4 book ai didi

Android Oreo 8.0 native C++ 崩溃 : invalid pthread_t passed to libc

转载 作者:搜寻专家 更新时间:2023-11-01 09:31:55 24 4
gpt4 key购买 nike

我有一个 Android 应用程序,它使用 Cmake 将 native 代码编译到我的应用程序中,并且它在运行 Android 7.1 的 Pixel 设备上运行良好。我决定将我的 Pixel 设备升级到 Oreo 8.0,现在我无法在我的应用程序中输入 native C++ 代码。

这是崩溃时的 logcat 转储:

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代码

add_library(NativeLib SHARED IMPORTED)
set_property(TARGET NativeLib PROPERTY IMPORTED_LOCATION "${PROJECT_SOURCE_DIR}/NativeLib/Android/Release/${ANDROID_ABI}/libNativeLib.so")

然后共享库链接到目标。

正如我所说,这一切都在 Android 7.1 上完美运行,将设备升级到 8.0 导致了这次崩溃,这是一个新的错误吗?我确实在这里阅读了 8.0 的“ native 库”更改 https://developer.android.com/about/versions/oreo/android-8.0-changes.html .

我还在我的库上运行了 readelf 并取回了它,这对于 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中,一个致命的问题将会发生。

无论如何,这需要更小心地处理 POSIX 内容......

查看 pthread_internal.cpp 中的最后一个代码块供引用。

关于Android Oreo 8.0 native C++ 崩溃 : invalid pthread_t passed to libc,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46457800/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com