Bug#191395: clone(...) makes defunct threads when linked with pthread
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 problem is that if the c-program below is compiled with gcc 2.95.3:
gcc libc_bug.c -o test
then it makes 10 threads and they function allright!
But if I compile with:
gcc -lpthread libc_bug.c -o test
then the call to clone returns the pid of the child (no error but the
actual thread pid), and the thread is created but is defunct, and the
specified method is never called!!
Now the Really strange part if I compile with:
gcc /usr/lib/libpthread.a libc_bug.c -o test
then it works just fine???
The problem has also been identified on a system using libc-dev 2.2.5-11.5
running kernel 2.4.19
I have degenerated, and tried the below program on a RedHat machine
running kernel 2.4.18 , gcc 2.96 and libc6-dev 2.2.4-13
On this machine there are no problems when linking both dynamic and static
with pthreads......
//program
#include <sched.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#define STACK_SIZE 16384
int dummy(void *_arg) {
int p = *(int*)_arg;
fprintf(stderr,"Child has pid = %d \n", getpid());
sleep(100);
return 0;
}
int main(int argc, char *argv) {
void *stack;
int pid;
int arg;
int i;
for (i=0; i<10; i++) {
//make stack
stack = malloc(STACK_SIZE);
//stack grows down
stack = (void*)((unsigned int)stack + STACK_SIZE);
arg = i;
pid = clone(dummy, stack, CLONE_FS | CLONE_FILES | CLONE_VM | CLONE_SIGHAND, (void*)&arg);
fprintf(stderr,"Main created Thread with pid %d \n", pid);
sleep(1);
} // end forloop
while(1) {
sleep(10);
}
return 0;
}
/Christian Thomsen
/DAT 8
/Aalborg Universitet
/Denmark
Reply to: