This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
bug with PI mutex and static linking
- From: "Warlich, Christof" <christof dot warlich at siemens dot com>
- To: "libc-help at sourceware dot org" <libc-help at sourceware dot org>
- Date: Thu, 11 Feb 2016 10:03:33 +0000
- Subject: bug with PI mutex and static linking
- Authentication-results: sourceware.org; auth=none
Dear all,
with glibc 2.22, the following test fails on x86_64 when statically linking with EPERM when doing the pthread_mutex_unlock(). It looks like mutex->__data.__owner is not properly initialized, as it is 0 when trying to unlock.
This worked fine with glibc 2.18 and still works with glibc 2.22 when dynamically linking.
Is this a known regression, maybe even with a patch being available already?
Thanks for any help,
Chris
// compiled with gcc -static -pthread test.c
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
#include <assert.h>
pthread_mutex_t mymutex;
int main(int argc, char *argv[])
{
pthread_mutexattr_t attr;
assert(!pthread_mutexattr_init(&attr));
assert(!pthread_mutexattr_setprotocol(&attr, PTHREAD_PRIO_INHERIT));
assert(!pthread_mutex_init(&mymutex, &attr));
assert(!pthread_mutex_lock(&mymutex));
printf("locked b\n");
assert(!pthread_mutex_unlock(&mymutex));
pthread_mutex_destroy(&mymutex);
return EXIT_SUCCESS;
}