Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Close Windows handle from _beginthreadex

Closed / Accepted442646ffffffffffffffffffffffffffffffffffCreated 25 years agoUpdated 25 years ago
Descriptionplain2001-07-19 02:14:06
The documentation for the _beginthreadex method
indicates that the caller is responsible for
closing the returned HANDLE object. Tcl does
not close this handle which seems like a memory
leak to me. The following patch should fix the
problem, but if someone that knows a bit more
about Windows threads could take a peek I would
feel much better about it. The part I am unsure
of is if it is ok to call CloseHandle() on
a thread handle that is currently alive.


Here are some related URLs:

http://support.microsoft.com/support/kb/articles/q132/0/78.asp
http://technology.niagarac.on.ca/courses/comp831/win32/_beginthread.htm
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_crt__beginthread.2c_._beginthreadex.asp
http://www.microsoft.com/msj/0799/win32/win320799.htm


2001-07-18  Mo DeJong  <[email protected]>

* win/tclWinThrd.c (Tcl_CreateThread): Close Windows
HANDLE
returned by _beginthreadex since the MS documentation
states
that this handle is not closed by a later call to
_endthreadex.
mdejongplain2001-07-19 09:14:07
File Added - 8589: patch
hobbs Ticket [442646ffff]: 1 change [History diff]2001-07-20 05:26:26
mdejongplain2001-07-24 11:43:08
Logged In: YES 
user_id=90858

Any reaction to this patch? It is kind of holding up
another Cygwin patch so I if someone could take a
look at it that would be great. I ran the tcl tests
and the thread tests with this patch applied and
I did not notice any ill effects.
hobbsplain2001-07-25 02:02:17
Logged In: YES 
user_id=72656

Sorry, at the conference and right before makes things a 
little hectic for checking patches.  Anyway, this looks 
correct to me.  If it passes 'make test' on Windows with 
and without --enable-symbols, then I'd say put it in.
mdejongplain2001-07-25 02:49:59
Logged In: YES 
user_id=90858

Ok, I am adding this patch since it does not
change any of the test results and should plug
a memory leak.
Log in (anonymous is fine) to add a comment.

Attachments: