Hi all.

New try to see if somebody knows anything on this.
Summary: compiling with gcc -pthread breaks the clone() system call in glibc.
It never calls the target function.
I have tested it in several systems: Cooker, Mdk8.2 and RH7.2. Only RedHat
works.

Below is a simple script to test the thing. Here are the results. Systems
are an up-to-the-minute Cooker, an stock 8.2 (well, perhaps some security
update but nothing from cooker for sure), and an stock RedHat 7.2:

========== Cooker
werewolf:~/bp/cl> clone-tst.sh
Mandrake Linux release 8.3 (Cooker) for i586
gcc-3.1.1-0.4mdk
glibc-2.2.5-6mdk

gcc
about to clone...
clone ok
slave runs <================
slave done

gcc -pthread
about to clone...
clone ok
slave done

========== Mandrake 8.2
annwn:~> clone-tst.sh
Mandrake Linux release 8.2 (Bluebird) for i586
gcc-2.96-0.76mdk
glibc-2.2.4-25mdk

gcc
about to clone...
clone ok
slave runs <================
slave done

gcc -pthread
about to clone...
clone ok
slave done

========== RedHat 7.2
leda:~> clone-tst.sh
Red Hat Linux release 7.2 (Enigma)
gcc-2.96-98
glibc-2.2.4-19.3

gcc
about to clone...
clone ok
slave runs <================
slave done

gcc -pthread
about to clone...
slave runs <================
clone ok
slave done

?????

clone-tst.sh:

#!/bin/bash

cat > cl.c << @EOF
#include <sched.h>
#include <signal.h>
#include <stdio.h>

#define STSZ (4*1024)

int pslave(void *data)
{
        puts("slave runs <================");
        return 0;
}

int main(int argc,char** argv)
{
        char*   stack;

        stack = (char*)valloc(STSZ);
        puts("about to clone...");
        clone(pslave,stack+STSZ-1,CLONE_VM|CLONE_FILES|SIGCHLD,0);
        puts("clone ok");
        wait(0);
        puts("slave done");
        free(stack);

        return 0;
}
@EOF

gcc -o cl0 cl.c
gcc -pthread -o cl1 cl.c
rm -f cl.c

cat /etc/redhat-release
rpm -q gcc
rpm -q glibc
echo

echo "gcc"
cl0
echo
echo "gcc -pthread"
cl1
echo

-- 
J.A. Magallon             \   Software is like sex: It's better when it's free
mailto:[EMAIL PROTECTED]  \                    -- Linus Torvalds, FSF T-shirt
Linux werewolf 2.4.19-pre10-jam3, Mandrake Linux 8.3 (Cooker) for i586
gcc (GCC) 3.1.1 (Mandrake Linux 8.3 3.1.1-0.4mdk)

Reply via email to