-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Programe exited after call pthread_completejoin() many times on ESP32 #12096
Comments
Hi, @HongxiaWangSSSS joininfo will not be released until the task group is destroyed: |
I tried to run the test code in the C native, the test case works as expected:
./tools/configure.sh sabre-6quad/nsh
|
Hi, Thank you for the test !!!🙇 BR, |
I probably know the root cause. after the introduction of #11898, the detached thread will not destroy the joininfo. In your test case, a large number of pthreads will be created with detached attribute, so there will be many joininfo pending in the task group,each of joininfo is to ensure that pthread_join() could gets the correct return value: joining a detached/canceled thread should return EINVAL, not ESRCH https://github.com/apache/nuttx/blob/master/sched/pthread/pthread_join.c#L92-L102 since many of joininfo will consume too much memory, I think this is not friendly to embedded MCU devices,maybe we can keep the semantics before #11898 was introduced, @xiaoxiang781216 how do you think? |
thread should release joininfo after detaching, since nobody will call pthread_join. |
@HongxiaWangSSSS please try PR #12106 |
yes, it worked!! |
Hi, @anchao
When I tested a multi-threaded stress test case, I found that after introducing (#11898), my program would exit with status code = 12.
The test log as below:
After debugging I found in the function
pthread_findjoininfo
it will malloc some memory, but doesn't free it, like: https://github.com/apache/nuttx/blob/master/sched/pthread/pthread_completejoin.c#L100C1-L101C1 (there are other places similar to this),So I'm a little curious about the reason and hope if you could help me~ Thank U
BR,
Hongxia
The text was updated successfully, but these errors were encountered: