Comment 10 for bug 1035572

Revision history for this message
Dietmar Stölting (dietmar-stoelting) wrote :

I just compare the source code for testthread.c and testclone.c.
The only difference I see is, HOW the function clone() is called.
In testthread via pthread_create()
in testclone via clone() direct.
So, the problem for qemu-i386 must be in the settings of the flags in clone().

Works:

void test_pthread(void)
{
    pthread_t tid1, tid2;

    pthread_create(&tid1, NULL, thread1_func, "hello1");
    pthread_create(&tid2, NULL, thread2_func, "hello2");
    pthread_join(tid1, NULL);
    pthread_join(tid2, NULL);
    printf("End of pthread test.\n");
}

Works not:

void test_clone(void)
 {
 uint8_t *stack1, *stack2;
 int pid1, pid2, status1, status2;

 stack1 = malloc(STACK_SIZE);
 pid1 = clone(thread1_func, stack1 + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello1");

 stack2 = malloc(STACK_SIZE);
 pid2 = clone(thread2_func, stack2 + STACK_SIZE, CLONE_VM | CLONE_FS | CLONE_FILES | SIGCHLD, "hello2");

 while (waitpid(pid1, &status1, 0) != pid1);
 while (waitpid(pid2, &status2, 0) != pid2);

 printf("status1=0x%x\n", status1);
 printf("status2=0x%x\n", status2);
 printf("End of clone test.\n");
 }

Nice to hear from you,
Dietmar