bug with PI mutex and static linking

Warlich, Christof christof.warlich@siemens.com
Thu Feb 11 10:03:00 GMT 2016


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;
}



More information about the Libc-help mailing list