This is the mail archive of the
mailing list for the pthreas-win32 project.
Re: Pthread_join waits endlessly for already ended thread
Virgilio Alexandre Fornazin wrote:
This is good to know in case all else fails.
I had a problem similar to this, and creating an event handle for signaling
I had this problem in plain win32 threads before. This always happened in
It´s probably a bad design / limitation in win32 shared library model. The
cause, if I remember,
is that the heap is locked in some way that functions related to thread
(TerminateThread if I'm
not missing other) must access this heap, then it deadlocks in some locking
Windows have internally.
The library does have a compile-time condition that will cause threads
to enter/exit via _beginthread()/_endthread() rather than the preferred
_beginthreadex()/_endthreadex() versions, and MS documentation does say
that _endthread() closes the Win32 thread handle resulting in no
signalling, e.g. to WaitFor*(). This is one case that does exist in the
library and needs to be fixed unless I'm mistaken.
The pre-built pthreads-win32 DLLs should be using _endthreadex() but in
this case it is still the exiting thread that explicitly closes the
Win32 thread handle before _endthreadex() is called. I'd like to move
that close to the joining thread.