Julien PUYDT has brought this interesting scenario to my attention. He also wrote the supplied test program.
It is possible that a program can end up using pthreads without actually linking to them directly. For instance, programs which use dlopen and family to load DSOs may not be multithreaded themselves, however, the DSO may be. In this case, the DSO can end up crashing the application (a program demonstrating this is attached). Although it is easy to make pthreads capable of detecting this case and then "upgrading" unknown threads to pthreads, we have to change __hurd_threadvar_stack_mask and __hurd_threadvar_stack_offset. The result is that the main thread's TSD is no longer accessible and the program soon crashes. Would it be possible to special case the main thread in a similar way as the signal thread (of course, how to we even get the stack bounds?). Perhaps there is something else that we can do. This is a bit hacky and I am not even sure that POSIX says that we have to support this feature (although the description of pthread_atfork alludes to something similar). Either way, I cannot find any wording that might preclude it. As a side note, linuxthreads covers this case. Thanks, Neal Test program: There are two files: test.c and test-lib.c. Compile using: gcc -ldl -o test test.c gcc -shared -fPIC -lpthread -o test-lib.so test-lib.c test.c: #include <dlfcn.h> #include <stdio.h> int main(void) { void *handle = NULL; int (*plugin_function)(void); handle = dlopen ("./test-lib.so", RTLD_LAZY); plugin_function = (int (*)(void)) dlsym (handle, "externally_called"); if((*plugin_function) () == 0) printf("ok\n"); else printf("bad\n"); exit(0); } test-lib.c: #include <pthread.h> void * loop (void *dummy) { while (1) sched_yield (); } int externally_called() { pthread_t pth; pthread_create (&pth, 0, loop, 0); return 0; } _______________________________________________ Bug-hurd mailing list [EMAIL PROTECTED] http://mail.gnu.org/mailman/listinfo/bug-hurd