[Bug 1427981] Re: pthread_join failure
Jan-Benedict Glaw
jbglaw at lug-owl.de
Fri Feb 2 19:46:38 UTC 2018
I saw ESRCH problems on one of our applications, which unfortunately
leads to aborts() from within libmicrohttpd under certain circumstances.
Looking at your sample code, I guess that its main problem is the way
you're receiving the thread return value off pthread_join(). Look
carefully at it, you're getting a void * assigned to an integer
(submitted through the void ** supplied to pthread_join())! So that int
shall hold all of a pointer, which formally won't work, and may or may
not work, depending on whether or not you're on a 32 bit architecture.
You are, however, on a amd64 host, so the program isn't correct here.
-f{no-,}stack-protector may change the stack layout, that's why you're
seeing differences in testcase execution.
That said, on success, your index variable (i) is overwritten by the
NULL pointer received from the thread function on success. That's why
you always start with i=0 after a successful pthread_join().
That, unfortunately, invalidates the test case, and I need to continue
to find the root cause of my very own problem. ;-)
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to glibc in Ubuntu.
https://bugs.launchpad.net/bugs/1427981
Title:
pthread_join failure
Status in glibc package in Ubuntu:
New
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 at tests]$cat /etc/issue
Ubuntu 14.04 LTS \n \l
[macbeth at 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 at tests]$dpkg -l libc6
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-======================================-========================-========================-==================================================================================
ii libc6:amd64 2.19-0ubuntu6 amd64 Embedded GNU C Library: Shared libraries
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1427981/+subscriptions
More information about the foundations-bugs
mailing list