public inbox for pthreads-win32@sourceware.org
 help / color / mirror / Atom feed
From: Ross Johnson <Ross.Johnson@homemail.com.au>
To: pthreads-win32@sourceware.org
Subject: Re: Pthread_join waits endlessly for already ended thread
Date: Fri, 20 Mar 2009 23:37:00 -0000	[thread overview]
Message-ID: <49C427D7.3090505@homemail.com.au> (raw)
In-Reply-To: <00c801c9a889$66077340$321659c0$@com.br>

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.

  reply	other threads:[~2009-03-20 23:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-16 13:14 Torsten Andre2
2009-03-19  0:34 ` Ross Johnson
2009-03-19 11:54   ` Virgilio Alexandre Fornazin
2009-03-20 23:37     ` Ross Johnson [this message]
2009-03-22 21:51       ` good job! Michel Pacilli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49C427D7.3090505@homemail.com.au \
    --to=ross.johnson@homemail.com.au \
    --cc=pthreads-win32@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).