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

Activate thread pool will cause crash. #21461

Open
xiaojingang1777 opened this issue Jul 23, 2024 · 3 comments
Open

Activate thread pool will cause crash. #21461

xiaojingang1777 opened this issue Jul 23, 2024 · 3 comments
Labels
platform:mobile issues related to ONNX Runtime mobile; typically submitted using template stale issues that have not been addressed in a while; categorized by a bot

Comments

@xiaojingang1777
Copy link

Describe the issue

My program dlopen libonnxruntime.so, the infence works fine, but when dlclose all the so, the main program crash.
If I activate disable thread pool by set _OrtSessionOptions.SetIntraOpNumThreads(1);
the main program won't crash, but the infence speed will be very slow.

From the onnxruntime source code comment:
ORT_RUNTIME_CLASS(Session); // Don't call ReleaseSession from Dllmain (because session owns a thread pool)
Whether my case violation this, and how to use thread pool, and release the thread pool after infence finished.

To reproduce

N/A

Urgency

No response

Platform

Android

OS Version

Android 7.0

ONNX Runtime Installation

Built from Source

Compiler Version (if 'Built from Source')

No response

Package Name (if 'Released Package')

None

ONNX Runtime Version or Commit ID

V1.18

ONNX Runtime API

C++/C

Architecture

ARM64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@xiaojingang1777 xiaojingang1777 added the platform:mobile issues related to ONNX Runtime mobile; typically submitted using template label Jul 23, 2024
@xiaojingang1777
Copy link
Author

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 : UNeedCryDear/yolov8-opencv-onnxruntime-cpp#1 pc 000000000001bd78 /system/lib64/libc.so (__cxa_thread_finalize+36)
07-23 13:59:43.253 32076 32076 F DEBUG : UNeedCryDear/yolov8-opencv-onnxruntime-cpp#2 pc 0000000000067fc8 /system/lib64/libc.so (pthread_exit+20)
07-23 13:59:43.253 32076 32076 F DEBUG : UNeedCryDear/yolov8-opencv-onnxruntime-cpp#3 pc 0000000000067ec0 /system/lib64/libc.so (_ZL15__pthread_startPv+200)
07-23 13:59:43.253 32076 32076 F DEBUG : UNeedCryDear/yolov8-opencv-onnxruntime-cpp#4 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
Copy link
Author

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

Copy link
Contributor

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Aug 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform:mobile issues related to ONNX Runtime mobile; typically submitted using template stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

1 participant