Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Tcl crash after unload on Windows 2000

Closed / Fixed620735ffffffffffffffffffffffffffffffffffCreated 24 years agoUpdated 24 years ago
Descriptionplain2002-10-09 12:30:28
This bug took quite a while to track down.

It seems that during the initialization of the Tcl 
subsystems, a thread is created.  The threadProc 
for this thread is the CalibrationThread routine.

This thread enters an infinite loop at priority 11 
and continues to run AFTER the Tcl DLL has been 
unloaded.  This causes the process to crash.

My suggestion on a fix is that at some point during 
the finalization of Tcl, TerminateThread be called 
on the saved thread handle for this thread.  No ill 
effects should occur due to this thread being 
terminated.  I believe it's in the 
variable "timeInfo.calibrationThread" in 
file "win/tclWinTime.c".

JJM
dkf Ticket [620735ffff]: 2 changes [History diff]2002-10-09 19:39:48
nobodyplain2002-10-09 19:51:28
Logged In: NO 


After some thought, I believe a much cleaner solution 
would be to use SleepEx in the CalibrationThread 
routine (with the bAlertable flag set to TRUE) and then to 
send the thread a "deadly" APC via QueueUserAPC 
(portable to Win 95+ and Win NT4+).  The APC routine 
should simply call ExitThread.  The handle to pass to 
QueueUserAPC can be had from the 
variable "timeInfo.calibrationThread" 
in "win/tclWinTime.c".

JJM
kennykbplain2002-10-10 06:59:32
Logged In: YES 
user_id=99768

Better still is to set an event to 
ask the thread politely to exit,
and let it do so.  That's what 
the committed fix does.
Log in (anonymous is fine) to add a comment.