Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libMNN.so在android上会偶现多线程crash问题 #1927

Closed
keke444 opened this issue May 19, 2022 · 8 comments
Closed

libMNN.so在android上会偶现多线程crash问题 #1927

keke444 opened this issue May 19, 2022 · 8 comments

Comments

@keke444
Copy link

keke444 commented May 19, 2022

 在Ubuntu 18.04平台上编译了1.2.0版本的libMNN.so 在android手机上测试时,会 偶然出现以下的crash问题

D91D34 05-15 17:47:37.583 30895 30895 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
CD91D35 05-15 17:47:37.583 30895 30895 F DEBUG : Native Crash TIME: 167356540
CD91D36 05-15 17:47:37.583 30895 30895 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
CD91D37 05-15 17:47:37.583 30895 30895 F DEBUG : Build fingerprint: 'Nokia/Penguin_00WW/PGN:12/SP1A.210812.016/00WW_0_190:user/release-keys'
CD91D38 05-15 17:47:37.583 30895 30895 F DEBUG : Revision: '0'
CD91D39 05-15 17:47:37.583 30895 30895 F DEBUG : ABI: 'arm'
CD91D3A 05-15 17:47:37.583 30895 30895 F DEBUG : Timestamp: 2022-05-15 17:47:36.621948243+0800
CD91D3B 05-15 17:47:37.583 30895 30895 F DEBUG : Process uptime: 0s
CD91D3C 05-15 17:47:37.583 30895 30895 F DEBUG : Cmdline: /vendor/bin/hw/android.hardware.camera.provider@2.4-service
CD91D3D 05-15 17:47:37.583 30895 30895 F DEBUG : pid: 10799, tid: 30887, name: gd_oem >>> /vendor/bin/hw/android.hardware.camera.provider@2.4-service <<<
CD91D3E 05-15 17:47:37.583 30895 30895 F DEBUG : uid: 1047
SD91D3F 05-15 17:47:37.583 1140 4347 D WindowManager: Relayout Window=Window{ac5b6fa u0 com.android.camera2/com.android.camera.CameraLauncher} ,oldVis=0 ,newVis=0 ,focusMayChange=false
CD91D40 05-15 17:47:37.583 30895 30895 F DEBUG : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
CD91D41 05-15 17:47:37.584 30895 30895 F DEBUG : Abort message: '/buildbot/src/android/ndk-release-r21/external/libcxx/../../external/libcxxabi/src/abort_message.cpp:72: abort_message: assertion "cannot create thread specific key for __cxa_get_globals()" failed'
CD91D42 05-15 17:47:37.584 30895 30895 F DEBUG : r0 00000000 r1 000078a7 r2 00000006 r3 d317d008
CD91D43 05-15 17:47:37.584 30895 30895 F DEBUG : r4 d317d01c r5 d317d000 r6 00002a2f r7 0000016b
CD91D44 05-15 17:47:37.584 30895 30895 F DEBUG : r8 d317d008 r9 d317d018 r10 d317d038 r11 d317d028
CD91D45 05-15 17:47:37.584 30895 30895 F DEBUG : ip 000078a7 sp d317cfd8 lr ecfbe909 pc ecfbe91c
CD91D46 05-15 17:47:37.584 30895 30895 F DEBUG : backtrace:
CD91D47 05-15 17:47:37.584 30895 30895 F DEBUG : #00 pc 0003891c /apex/com.android.runtime/lib/bionic/libc.so (abort+172) (BuildId: 679771dd555d9b049d218a1062b556ac)
CD91D48 05-15 17:47:37.584 30895 30895 F DEBUG : #1 pc 00038b93 /apex/com.android.runtime/lib/bionic/libc.so (__assert2+22) (BuildId: 679771dd555d9b049d218a1062b556ac)
CD91D49 05-15 17:47:37.584 30895 30895 F DEBUG : #2 pc 000969a7 /vendor/lib/libMNN.so (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D4A 05-15 17:47:37.584 30895 30895 F DEBUG : #3 pc 00094d71 /vendor/lib/libMNN.so (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D4B 05-15 17:47:37.584 30895 30895 F DEBUG : #4 pc 00081daf /apex/com.android.runtime/lib/bionic/libc.so (pthread_once+82) (BuildId: 679771dd555d9b049d218a1062b556ac)
CD91D4C 05-15 17:47:37.584 30895 30895 F DEBUG : #5 pc 00094d33 /vendor/lib/libMNN.so (__cxa_get_globals_fast+14) (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D4D 05-15 17:47:37.584 30895 30895 F DEBUG : #6 pc 00094ce1 /vendor/lib/libMNN.so (__cxa_get_globals+4) (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D4E 05-15 17:47:37.584 30895 30895 F DEBUG : #7 pc 000948b7 /vendor/lib/libMNN.so (__cxa_throw+14) (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D4F 05-15 17:47:37.584 30895 30895 F DEBUG : #8 pc 0009385d /vendor/lib/libMNN.so (std::__ndk1::__throw_system_error(int, char const*)+56) (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D50 05-15 17:47:37.584 30895 30895 F DEBUG : #9 pc 00093a7d /vendor/lib/libMNN.so (std::__ndk1::__thread_specific_ptrstd::__ndk1::__thread_struct::__thread_specific_ptr()+24) (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D51 05-15 17:47:37.584 30895 30895 F DEBUG : #10 pc 00093a3d /vendor/lib/libMNN.so (std::__ndk1::__thread_local_data()+40) (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
CD91D52 05-15 17:47:37.584 30895 30895 F DEBUG : #11 pc 0008cffb /vendor/lib/libMNN.so (BuildId: 0464cc470db9ffa1f6c450cc0abb71e05870e14c)
SD91D53 05-15 17:47:37.584 1140 4347 V WindowManager: prepareSurfaceLocked controller mSurfaceController: Surface(name=com.android.systemui.ImageWallpaper)/@0xc537206 mLastHidden: true mLastAlpha: 1.0 mShownAlpha: 1.0 mAlpha: 1.0 w.isParentWindowHidden(): false w.isOnScreen(): false win: Window{2d2be48 u0 com.android.systemui.ImageWallpaper}
CD91D54 05-15 17:47:37.584 30895 30895 F DEBUG : #12 pc 00080853 /apex/com.android.runtime/lib/bionic/libc.so (__pthread_start(void*)+40) (BuildId: 679771dd555d9b049d218a1062b556ac)
CD91D55 05-15 17:47:37.585 30895 30895 F DEBUG : #13 pc 00039875 /apex/com.android.runtime/lib/bionic/libc.so (__start_thread+30) (BuildId: 679771dd555d9b049d218a1062b556ac)

请问这会是什么原因导致的?

@jxt1234
Copy link
Collaborator

jxt1234 commented May 19, 2022

开启了 openmp ?

@Pony23333
Copy link

我在安卓上遇到了类似的问题,addr2line的结果是,请问如何解决
lQLPDhtwMhjdJYZhzQLTsKybUgFlPIBiAoh-n0tA9gA_723_97

@keke444
Copy link
Author

keke444 commented May 19, 2022

开启了 openmp ?
并没有开

@jxt1234
Copy link
Collaborator

jxt1234 commented May 19, 2022

有可能是线程句柄不够了。。。 是什么类型的 android 机器

@keke444
Copy link
Author

keke444 commented May 23, 2022

有可能是线程句柄不够了。。。 是什么类型的 android 机器

我们用的就是原生的android机器,线程句柄不够是什么意思呢?内存还是啥

@jxt1234
Copy link
Collaborator

jxt1234 commented May 30, 2022

就是 android 里面一个 app 所能创建的线程数是有限制的,超过就会报句柄不够而崩溃,有可能你 app 其他代码创建了很多线程。这个一般在比较低端的 android 机器上出现,可以看下是否是低端机

@keke444
Copy link
Author

keke444 commented Jul 13, 2022

就我们在crash中,看到编译工具ndk的问题,想知道编译libmnn.so 时,跟ndk的版本有关系吗?以及-DANDROID_TOOLCHAIN=clang 有关系吗?会不会用gcc更好,cmake编译设置如下:
#!/bin/bash
cmake ../../../
-DCMAKE_TOOLCHAIN_FILE=/docker/tensorflow/android-ndk-r21/build/cmake/android.toolchain.cmake
-DCMAKE_BUILD_TYPE=Release
-DANDROID_ABI="armeabi-v7a"
-DANDROID_STL=c++_static
-DCMAKE_BUILD_TYPE=Release
-DANDROID_NATIVE_API_LEVEL=android-21
-DANDROID_TOOLCHAIN=clang
-DMNN_USE_LOGCAT=false
-DMNN_USE_SSE=OFF
-DMNN_SUPPORT_BF16=OFF
-DMNN_BUILD_TEST=ON
-DMNN_BUILD_FOR_ANDROID_COMMAND=true
-DNATIVE_LIBRARY_OUTPUT=. -DNATIVE_INCLUDE_OUTPUT=. $1 $2 $3

make -j4

感觉有没有可能是多线程保护机制有关?我们这crash大概是跑个一两百次才会出现,觉得很奇怪?

谢谢

@jxt1234
Copy link
Collaborator

jxt1234 commented Jul 13, 2022

android ndk 可以更新到 21 及以上试试,后续的 ndk 都是用 clang 的,按理是 clang 更好

@keke444 keke444 closed this as completed Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants