Skip to contentSkip to conversation

New: main() not exited normally then using pthreads

Buildroot bugzilla at busybox.net 1 participant 8 messages Nov 25, 2011 – Apr 4, 2013

lore
Share & tools
lore
#0 lore raw

https://bugs.busybox.net/show_bug.cgi?id=4538

Summary: main() not exited normally then using pthreads
Product: buildroot
Version: 2011.08
Platform: PC
OS/Version: Linux
Status: NEW
Severity: major
Priority: P5
Component: Other
AssignedTo: unassigned at buildroot.uclibc.org
ReportedBy: sunheretic13 at gmail.com
CC: buildroot at uclibc.org
Estimated Hours: 0.0

Created attachment 3782
--> https://bugs.busybox.net/attachment.cgi?id=3782
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.

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
#1 lore raw

[Buildroot] [Bug 4538] main() not exited normally then using pthreads

https://bugs.busybox.net/show_bug.cgi?id=4538

--- Comment #1 from Boris Yaroslav <[email protected]> 2011-11-25 07:01:30 UTC --- Created attachment 3788
--> https://bugs.busybox.net/attachment.cgi?id=3788
Buildrootconfig file

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
#2 lore raw

[Buildroot] [Bug 4538] main() not exited normally then using pthreads

In reply to bugzilla at busybox.net

https://bugs.busybox.net/show_bug.cgi?id=4538

--- Comment #2 from Boris Yaroslav <[email protected]> 2011-11-25 07:02:19 UTC --- Created attachment 3794
--> https://bugs.busybox.net/attachment.cgi?id=3794
busybox-1.18.5 config

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
#3 lore raw

[Buildroot] [Bug 4538] main() not exited normally then using pthreads

In reply to bugzilla at busybox.net

https://bugs.busybox.net/show_bug.cgi?id=4538

--- Comment #3 from Boris Yaroslav <[email protected]> 2011-11-25 07:03:08 UTC --- Created attachment 3800
--> https://bugs.busybox.net/attachment.cgi?id=3800
uclibc-0.9.32 config

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
#4 lore raw

[Buildroot] [Bug 4538] main() not exited normally then using pthreads

In reply to bugzilla at busybox.net

https://bugs.busybox.net/show_bug.cgi?id=4538

--- Comment #4 from Boris Yaroslav <[email protected]> 2011-11-25 07:04:06 UTC --- Created attachment 3806
--> https://bugs.busybox.net/attachment.cgi?id=3806
linux kernel config

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
#5 lore raw

[Buildroot] [Bug 4538] main() not exited normally then using pthreads

In reply to bugzilla at busybox.net

https://bugs.busybox.net/show_bug.cgi?id=4538

--- Comment #5 from Michael J. Wang <[email protected]> 2013-04-01 23:24:18 UTC --- 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

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
#6 lore raw

[Buildroot] [Bug 4538] main() not exited normally then using pthreads

In reply to bugzilla at busybox.net

https://bugs.busybox.net/show_bug.cgi?id=4538

--- Comment #6 from Gustavo Zacarias <[email protected]> 2013-04-02 19:36:49 UTC --- And may i ask why don't you report this to the uClibc developers instead of Buildroot ones?

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
#7 lore raw

[Buildroot] [Bug 4538] main() not exited normally then using pthreads

In reply to bugzilla at busybox.net

https://bugs.busybox.net/show_bug.cgi?id=4538

Michael J. Wang <[email protected]> changed:

What |Removed |Added
----------------------------------------------------------------------------

                 CC|                            |mjwang at broadcom.com,
                   |                            |uclibc-cvs at uclibc.org
          Component|Other                       |Threads
            Version|2011.08                     |0.9.32
         AssignedTo|unassigned at buildroot.uclibc |unassigned at uclibc.org
                   |.org                        |
            Product|buildroot                   |uClibc
   Target Milestone|---                         |0.9.33.2

--- Comment #7 from Michael J. Wang <[email protected]> 2013-04-04 06:52:37 UTC --- (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

Signature · 3 lines
Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.