[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#191398: pthread_mutex_lock() has different behaviour - dynamic/static link



Package: libc6-dev
Version: 2.2.5-11.2
Severity: normal



-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux splint 2.4.20 #2 Fri Apr 11 18:38:04 CEST 2003 i686
Locale: LANG=C, LC_CTYPE=C



The program below has different behaviour if it is linked either dynamic
or static with pthread:

gcc -lpthread libc_bug.c -o test
cannot reaquire the lock

whereas

gcc /usr/lib/libpthread.a libc_bug.c -o test

can reaquire forever..

also just

gcc libc_bug.c -o test
can reaquire the lock forever






 //program

#include <stdio.h>
#include <stdlib.h>
#include <pthread.h>

pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;

int main(int argc, char *argv) {
        while(1) {
		pthread_mutex_lock(&mutex);
		fprintf(stderr,"GOT LOCK\n");
		pthread_mutex_lock(&mutex);
		fprintf(stderr,"GOT LOCK\n");
		pthread_mutex_lock(&mutex);
		fprintf(stderr,"GOT LOCK\n");
        }
        return 0;
}


/Christian Thomsen
/DAT 8
/Aalborg Universitet
/Denmark





Reply to: