Tcl Source Code

View Ticket
Login
Ticket UUID: 1538926
Title: exit in thread crashes tclsh
Type: Bug Created on: 2006-08-11 20:06:30
Submitter: mpc_janssen Assigned to: vasiljevic
Subsystem: 49. Threading Severity:
Priority: 5 Medium Last modified: 2006-08-15 00:37:44
Status: Closed Closed by: vasiljevic
Resolution: Wont Fix Closed on: 2006-08-14 09:07:28
Version: obsolete: 8.4.13
Description:
When executing the following code in a thread enabled 
tclsh, the tclsh crashes on an access violation on 
Windows XP

package require Thread
thread::send [thread::create] exit

Some information:

% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine)   = intel
tcl_platform(os)        = Windows NT
tcl_platform(osVersion) = 5.1
tcl_platform(platform)  = windows
tcl_platform(threaded)  = 1
tcl_platform(user)      = mjanssen
tcl_platform(wordSize)  = 4
% puts $tcl_version
8.4
% puts $tcl_patchLevel
8.4.13
User Comments:
mpc_janssen added on 2006-08-12 06:12:30:
Logged In: YES 
user_id=1463011

Further testing shows that in a threaded Tcl8.5a4 it works:

C:\Tcl85\bin>tclsh85t.exe
% parray tcl_platform
tcl_platform(byteOrder) = littleEndian
tcl_platform(machine)   = intel
tcl_platform(os)        = Windows NT
tcl_platform(osVersion) = 5.1
tcl_platform(platform)  = windows
tcl_platform(threaded)  = 1
tcl_platform(user)      = mjanssen
tcl_platform(wordSize)  = 4
% exit

C:\Tcl85\bin>tclsh85t.exe
% package require Thread
2.6.3
% thread::send [thread::create] exit
target thread died
%
C:\Tcl85\bin>

vasiljevic added on 2006-08-14 16:07:28:
Logged In: YES 
user_id=95086

Calling [exit] out of the non-startup thread is NOT supported with the 
current state of the Tcl library. You must make sure all your threads
are gone before attempting the [exit]. And you can attempt to call 
the [exit] only from the first (startup) therad in the process.
The fact that you got it to work in 8.5 is purely a coincidence. 
This cannot be solved easily w/o re-designing how the Tcl library
handles various system's teardown.

cc_benny added on 2006-08-15 00:37:44:
Logged In: YES 
user_id=143885

Tcl shouldn't crash, though, I think.  It should raise an
error.  The error message should explain what was wrong,
so that the coder knows how to fix it.