state-threads / pthreads interaction on Linux

Sascha Schumann <[email protected]> Tue, 26 Nov 2002 07:32:04 +0100 (CET)
Newsgroups gmane.comp.lib.state-threads.user
Message-ID <[email protected]>
    Hi,

    has anyone encountered the problem that it is apparently
    impossible to mix state threads and the pthreads library on
    Linux?

    Whenever I access errno in a st-managed thread, I get a
    segfault.  This is especially true for library wrappers such
    as connect() etc.

    I need the pthread library though for inter-process locking
    (either posix semaphores or pthread mutexes).

    Test case follows (compile with gcc -pthread).  It
    immediately segfaults on Linux/x86 with glibc-2.2.5.

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 1024 (LWP 16566)]
    __errno_location () at errno.c:25

    - Sascha

#include <errno.h>
#include <st.h>

void *go_start(void *x) {
    errno = -1;
    return 0;
}

void main(void) {
    st_init();
    st_thread_create(go_start, NULL, 0, 0);
    st_sleep(5);
}



-------------------------------------------------------
This SF.net email is sponsored by: Get the new Palm Tungsten T 
handheld. Power & Color in a compact size! 
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0002en