From: Stefano D'A. <zan...@gm...> - 2008-11-01 10:42:14
|
I investigated a bit into Syllable's source code and it seems like some weird stuff is going on... First, in pthread_exit(), this cycle seems to be broken: 231 while ( cleanup ) 232 { 233 if ( cleanup->routine ) 234 (*cleanup->routine) (cleanup->arg); 235 cleanup = cleanup->prev; 236 free( cleanup ); 237 } since after the first loop, cleanup points to a freed memory location, which shouldn't be considered valid any more (unless you have very very strange memory handling routines/conventions, but I doubt that). At first glance I'd say it should be more like this: while (cleanup) { if (cleanup->routine) (*cleanup->routine) (cleanup->arg); tmp = cleanup; cleanup = cleanup->prev; free(tmp); } Going back to the original problem, it seems like pthread_exit() completely destroys the thread, which is not a POSIX-compliant behaviour, since it won't be found by pthread_join()s happening after the thread has terminated. This would be ok for PTHREAD_CREATE_DETACHED threads, but the POSIX standards states that the default detachstate is PTHREAD_CREATE_JOINABLE. Stefano |