Hi,

I run the attached program with uclibc linuxthread.old, uclibc android and glibc nptl with different link options (static/shared) and (-lpthread/-lc -lpthread) [1].

It seems the -lc -lpthread is broken. It is because there no forwarder for __errno_location and __h_errno_location in shared mode. So the linker will take the first one it found : the libc one. The correct solution could be to do something similar to __pthread_mutex_init.

For static mode I think it can't be solved, but we should emit a link warning/error.


Matthieu

PS : linuxthread.old errno seems broken also on -lpthread mode...

[1]
linuxthread.old
*********************
-lpthread
m 0(=0)
t 0 (=0)
m 4(=1)
t 4(=4)
*********************
-lc -lpthread
m 0(=0)
t 1 (=0)
m 4(=1)
t 2(=4)
static
*********************
-lpthread
m 0(=0)
t 0 (=0)
m 4(=1)
t 4(=4)
*********************
-lc -lpthread
m 0(=0)
t 1 (=0)
m 4(=1)
t 2(=4)


android
*********************
-lpthread
m 0(=0)
m 1(=1)
t 0 (=0)
t 4(=4)
*********************
-lc -lpthread
m 0(=0)
m 1(=1)
t 2 (=0)
t 4(=4)
static
*********************
-lpthread
m 0(=0)
m 1(=1)
t 0 (=0)
t 4(=4)
*********************
-lc -lpthread
m 0(=0)
m 1(=1)
t 2 (=0)
t 4(=4)


glibc nptl
*********************
-lpthread
m 0(=0)
t 0 (=0)
m 1(=1)
t 4(=4)
*********************
-lc -lpthread
m 0(=0)
t 0 (=0)
m 1(=1)
t 4(=4)
static
*********************
-lpthread
m 0(=0)
t 0 (=0)
m 1(=1)
t 4(=4)
*********************
-lc -lpthread
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libpthread.a(lowlevellock.o): In function `__lll_lock_wait_private':
(.text+0x0): multiple definition of `__lll_lock_wait_private'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(libc-lowlevellock.o):(.text+0x0): first defined here /usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libpthread.a(lowlevellock.o): In function `__lll_unlock_wake_private':
(.text+0x110): multiple definition of `__lll_unlock_wake_private'
/usr/lib/gcc/i486-linux-gnu/4.3.2/../../../../lib/libc.a(libc-lowlevellock.o):(.text+0x30): first defined here
collect2: ld returned 1 exit status
#include <pthread.h>
#include <errno.h>
#include <stdio.h>
#include <unistd.h>

void *start(void *data)
{
	printf("t %d (=0)\n", errno);
	errno = 4;
	sleep(1);
	printf("t %d(=4)\n", errno);
	return NULL;
}

int main(void)
{
	pthread_t t;
	int ret;
	printf("m %d(=0)\n", errno);
	errno = 1;
	ret = pthread_create(&t, NULL, start, NULL);
	printf("m %d(=1)\n", errno);
	errno = 2;
	ret = pthread_join(t, NULL);
	return 0;
}
_______________________________________________
uClibc mailing list
[email protected]
http://busybox.net/cgi-bin/mailman/listinfo/uclibc

Reply via email to