This is the mail archive of the pthreads-win32@sourceware.org mailing list for the pthreas-win32 project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Pthread_join waits endlessly for already ended thread


Virgilio Alexandre Fornazin wrote:
I had a problem similar to this, and creating an event handle for signaling
solves nothing.

I had this problem in plain win32 threads before. This always happened in
DLL_PROCESS_DETACH. 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.
This is good to know in case all else fails.

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]