apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ed Holyat" <ehol...@olf.com>
Subject RE: [PATCH] APR thread handle leak on Windows
Date Tue, 07 Feb 2006 17:26:32 GMT

This same discussion happened about a year ago. 
 
The patch is not thread safe, because of a race condition in closing the
handle in the thread and joining the thread and/or detaching from
another thread.  I believe that the thread tests use to crash on win32.

The answer was to enforce the UNIX style that someone quoted from the
man pages: basically saying that apr_thread_join must be called.


-----Original Message-----
From: William A. Rowe, Jr. [mailto:wrowe@rowe-clan.net] 
Sent: Saturday, February 04, 2006 4:13 PM
To: Chris Storah
Cc: dev@apr.apache.org
Subject: Re: [PATCH] APR thread handle leak on Windows

Chris, and devs, I'm confused;

the thd->td handle *is* closed in apr_thread_join.  If we deploy this
patch
to accomodate a particular programming style, we lose valuable return
context
information, but more importantly, if you aren't invoking
apr_thread_join, then
on many flavors of *nix you aren't farming the zombie threads.

Note we also properly close thd->td within apr_thread_detach, for much
the
same reasons one or the other must be invoked on *nix.

This patch is problematic for me; anyone else have some thoughts to
share?

Bill

Chris Storah wrote:
> Enclosed is a patch to fix a leak in APR threads, due to _endthreadex

> not automatically closing the handle (unlike _endthread).
> 
> Chris
> 
> 
>
------------------------------------------------------------------------
> 
> --- thread.c	2005-12-30 15:44:05.000000000 +1100
> +++ thread.c.orig	2005-12-29 10:05:45.000000000 +1100
> @@ -137,10 +137,6 @@
>      apr_pool_destroy(thd->pool);
>      thd->pool = NULL;
>  #ifndef _WIN32_WCE
> -	/* need to close the handle as _endthreadex does not
automatically
> -	 * do this - unlike _endthread
> -	 */
> -	CloseHandle(thd->td);
>      _endthreadex(0);
>  #else
>      ExitThread(0);


Mime
View raw message