[nptl] more stdout issues

Natanael Copa natanael.copa at gmail.com
Mon Apr 12 19:21:36 UTC 2010


Hi,

something is definitively wrong with stdio used in threads on x86.

I have enabled run-time assertions and run this phello.c on a multicore box:

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

void * printmsg(char *s){
        printf("printmsg: %s\n", s);
        return;
}

void pthread_hello(void)
{
        pthread_t thread1, thread2;

        pthread_create(&thread1, NULL, (void*(*)(void *))printmsg,
                (void*)"Hello");

        pthread_create(&thread2, NULL, (void*(*)(void *))printmsg,
                (void*)"World!");

        pthread_join(thread1, NULL);
        pthread_join(thread2, NULL);
        return;
}

int main(int argc, char *argv[])
{
        pthread_hello();
        return 0;
}

I get this:
World!
./phello2: libc/stdio/_WRITE.c: 41: __stdio_WRITE: Assertion
`!((stream)->__bufpos - (stream)->__bufstart)' failed.
Aborted

Smells like stdio is not threads safe?

-nc


More information about the uClibc mailing list