race between exit() and pthread_exit() with static linking
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
glibc (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
When statically linking a C multi-threaded application, there is a race between pthread_exit() and exit() which may cause pthread_exit() to abort the program.
It appears the issue is due to the forced unwind executed by pthread_exit() failing because _Unwind_Find_FDE() returns NULL. Apparently, _Unwind_Find_FDE() returns NULL after __deregister_
The issue is easily reproducible (in my machine it occurs approximately in 1 out of 3 runs) when running the attached sample program under strace.
Steps to reproduce:
- build the attached source with `gcc thread_test.c -lpthread -static -o thread_test`
- run with `strace -f ./thread_test`
Example output:
```
<snip>
[pid 28302] +++ killed by SIGABRT (core dumped) +++
+++ killed by SIGABRT (core dumped) +++
Aborted (core dumped)
```
If the commented code in the sample source is uncommented, we can confirm that _Unwind_Find_FDE() sometimes returns NULL.
Ubuntu 18.04.6 LTS
Package: libc6 2.27-3ubuntu1.6
Source package: https:/
Thank you for taking the time to report this bug and helping to make Ubuntu better. Please execute the following command only once, as it will automatically gather debugging information, in a terminal:
apport-collect 1982326
When reporting bugs in the future please use apport by using 'ubuntu-bug' and the name of the package affected. You can learn more about this functionality at https:/ /wiki.ubuntu. com/ReportingBu gs.