yolov8-opencv-onnxruntime-cpp icon indicating copy to clipboard operation
yolov8-opencv-onnxruntime-cpp copied to clipboard

Crash when unload the so of onnxruntime.

Open xiaojingang1777 opened this issue 1 year ago • 3 comments

07-23 13:59:43.248 32076 32076 F DEBUG : pid: 30705, tid: 31908, name: CurProgram >>> com.Xjg.maxi <<< 07-23 13:59:43.248 32076 32076 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x764b690480 07-23 13:59:43.249 32076 32076 F DEBUG : x0 000000766d3e13c0 x1 0000000000000000 x2 0000007697a00000 x3 0000000000000019 07-23 13:59:43.249 32076 32076 F DEBUG : x4 00000000000001b6 x5 000000007182030d x6 000000767cef2a88 x7 000000766a84e020 07-23 13:59:43.249 32076 32076 F DEBUG : x8 000000764b690480 x9 7ace37599133aaee x10 7fffffffffffffff x11 0000000000000001 07-23 13:59:43.249 32076 32076 F DEBUG : x12 0000000000000000 x13 0000000000000000 x14 0000000000000000 x15 000000766aa5e9e0 07-23 13:59:43.249 32076 32076 F DEBUG : x16 00000076a26e4ec0 x17 00000076a268afb4 x18 00000000717a2468 x19 00000076281f6160 07-23 13:59:43.249 32076 32076 F DEBUG : x20 000000766ecfa450 x21 00000000000077f1 x22 00000076a1c27100 x23 0000007697bb6a00 07-23 13:59:43.249 32076 32076 F DEBUG : x24 000000766ecfa4d0 x25 0000000000105000 x26 7ace37599133aaee x27 000000000000000b 07-23 13:59:43.249 32076 32076 F DEBUG : x28 7ace37599133aaee x29 000000766ecfa3a0 x30 00000076a263ed7c 07-23 13:59:43.249 32076 32076 F DEBUG : sp 000000766ecfa390 pc 000000764b690480 pstate 0000000080000000 07-23 13:59:43.253 32076 32076 F DEBUG : 07-23 13:59:43.253 32076 32076 F DEBUG : backtrace: 07-23 13:59:43.253 32076 32076 F DEBUG : #00 pc 000000764b690480 07-23 13:59:43.253 32076 32076 F DEBUG : #01 pc 000000000001bd78 /system/lib64/libc.so (__cxa_thread_finalize+36) 07-23 13:59:43.253 32076 32076 F DEBUG : #02 pc 0000000000067fc8 /system/lib64/libc.so (pthread_exit+20) 07-23 13:59:43.253 32076 32076 F DEBUG : #03 pc 0000000000067ec0 /system/lib64/libc.so (_ZL15__pthread_startPv+200) 07-23 13:59:43.253 32076 32076 F DEBUG : #04 pc 000000000001d940 /system/lib64/libc.so (__start_thread+16)

Android ndk build the code, with onnxruntime h/so, the program works fine, but when my program so is released by dl close, the main program crashed.

Whether this is related to this comment: ORT_RUNTIME_CLASS(Session); // Don't call ReleaseSession from Dllmain (because session owns a thread pool)

xiaojingang1777 avatar Jul 23 '24 07:07 xiaojingang1777

默认好像是开启thread pool的,我关闭,设置_OrtSessionOptions.SetIntraOpNumThreads(1);就没问题,但是会慢很多,但是不设置1,就会在释放so的时候,崩溃在thread相关操作,有什么办法能够主动关闭thread pool么,在执行完之后。

xiaojingang1777 avatar Jul 23 '24 11:07 xiaojingang1777

安卓相关我不熟悉,所以无法帮到你。另外,这个问题最好去onnxruntime那边去找下有无解答,或者直接在那边提起issue。 https://github.com/microsoft/onnxruntime/issues

UNeedCryDear avatar Jul 24 '24 02:07 UNeedCryDear

安卓相关我不熟悉,所以无法帮到你。另外,这个问题最好去onnxruntime那边去找下有无解答,或者直接在那边提起issue。 https://github.com/microsoft/onnxruntime/issues

好的,感谢!!!

xiaojingang1777 avatar Jul 24 '24 09:07 xiaojingang1777