| Summary: | main() not exited normally then using pthreads | ||
|---|---|---|---|
| Product: | uClibc | Reporter: | Boris Yaroslav <sunheretic13> |
| Component: | Threads | Assignee: | unassigned |
| Status: | NEW --- | ||
| Severity: | major | CC: | buildroot, mjwang, uclibc-cvs |
| Priority: | P5 | ||
| Version: | 0.9.32 | ||
| Target Milestone: | 0.9.33.2 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: |
Source Code demonstrated a bug
Buildrootconfig file busybox-1.18.5 config uclibc-0.9.32 config linux kernel config |
||
Created attachment 3788 [details]
Buildrootconfig file
Created attachment 3794 [details]
busybox-1.18.5 config
Created attachment 3800 [details]
uclibc-0.9.32 config
Created attachment 3806 [details]
linux kernel config
We see this problem as well on the MIPS architecture with uClibc 0.9.32 (old stable pthreads). I managed to trace it down a bit more and it seems like the pthread_onexit_process function is called twice. The first time it is called, everything works as designed: main thread sends the REQ_PROCESS_EXIT message to the manager thread, and the manager thread sends the RESTART signal (32) to the main thread, and the main thread wakes up from its sigsuspend and collects the manager. But from my kernel tracing, I see that the main thread sends the same REQ_PROCESS_EXIT to the manager thread again and blocks in sigsuspend. This time, there is no manager thread to send the restart signal, so the main thread hangs in sigsuspend and cannot exit. We do not see this behavior in uClibc 0.9.29, which was the previous version that we were using. The simple fix/workaround to this problem is to add the following line in pthread_onexit_process after waitpid(__pthread_manager_thread.p_pid, NULL, __WCLONE); __pthread_manager_request = -1; But that does not address the root issue of why the pthread_onexit_process function is called twice. Michael And may i ask why don't you report this to the uClibc developers instead of Buildroot ones? (In reply to comment #6) Oh, I now see that "product" is set to "BuildRoot" instead of "uClibc". Fixing it now and see if that will get the attention of the uClibc developers. Michael |
Created attachment 3782 [details] Source Code demonstrated a bug Architecture: x86. When I build system with buildroot-2011.08 with uclibc-0.9.32 (old stable threads)simple program not working properly. main function not exited normally. Program not stopped, until I not press Ctrl-C. But if I put _exit() at the end of main(), the program exited normally??? Attach: simple program source code.