pthread_join failure
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
pthread_join() appears to behave differently depending on gcc optimization is on or off. Build the attached source file with gcc -O2 or gcc -O0 has shown different joining results.
E.g., with `gcc pthread_join.c -lpthread -g -O2` it passes without issue.
with `gcc pthread_join.c -lpthread -g -O0`, the program fails at pthread_join() with ESRCH.
The same does not happen on other distros (tested on CentOS and Fedora).
Some additional info:
[macbeth@tests]$cat /etc/issue
Ubuntu 14.04 LTS \n \l
[macbeth@tests]$gcc --version
gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[macbeth@
Desired=
| Status=
|/ Err?=(none)
||/ Name Version Architecture Description
+++-===
ii libc6:amd64 2.19-0ubuntu6 amd64 Embedded GNU C Library: Shared libraries
tags: | added: trusty |
Another thing to note, which might be root cause of the bug, is that join_func() appears to be called multiple times according to the program output:
Joining thread 0
thread 0 joined!
Joining thread 1
thread 0 joined!
Joining thread 1
There is no way the program would want to join a thread multiple times.