Tcl Source Code

View Ticket
Login
Ticket UUID: 898342
Title: error from thread for code different from TCL_OK
Type: Bug Created on: 2004-02-16 22:16:19
Submitter: marcomaggi Assigned to: vasiljevic
Subsystem: 49. Threading Severity:
Priority: 5 Medium Last modified: 2004-06-21 13:45:22
Status: Closed Closed by: vasiljevic
Resolution: Fixed Closed on: 2004-06-21 06:45:22
Version: None
Description:
The following script crashes TCL 8.4.5 with Thread 2.5,
and only
makes Thread 2.5.2 output an error.

package require Tcl 8.4
package require Thread 2.5

set thread [thread::create -joinable -preserved]
thread::send -async $thread {
    break
} result
vwait result

# we never reach this point.
thread::release $thread
thread::join $thread
exit 0

The problem is triggered by [break], [continue] and
[return]: all
the commands that return a value different from TCL_OK.

When trying with Thread 2.5 the trace is:

Program received signal SIGSEGV, Segmentation fault.
...
#0  0x401e303f in strlen () from /lib/libc.so.6
#1  0xbffff754 in ?? ()
#2  0x400bbdb8 in Tcl_DbNewStringObj (
    bytes=0x61616161 <Address 0x61616161 out of
bounds>, length=-1, 
    file=0x400e3bbf "./../generic/tclVar.c", line=1395)
    at ./../generic/tclStringObj.c:265
#3  0x400c64a6 in Tcl_SetVar2 (interp=0x804ec90,
part1=0x402f0ae7 "errorCode", 
    part2=0x0, newValue=0x61616161 <Address 0x61616161
out of bounds>, flags=1)
    at ./../generic/tclVar.c:1395
#4  0x400c6465 in Tcl_SetVar (interp=0x804ec90,
varName=0x402f0ae7 "errorCode", 
    newValue=0x61616161 <Address 0x61616161 out of
bounds>, flags=1)
    at ./../generic/tclVar.c:1342
#5  0x402e5a4c in ThreadClbkSetVar (interp=0x804ec90,
clientData=0x80897c8)
    at ../generic/threadCmd.c:1379
#6  0x402e78eb in ThreadEventProc (evPtr=0x811d698,
mask=-3)
    at ../generic/threadCmd.c:2626
#7  0x400a90f1 in Tcl_ServiceEvent (flags=-3) at
./../generic/tclNotify.c:625
#8  0x400a95a1 in Tcl_DoOneEvent (flags=-3) at
./../generic/tclNotify.c:930
#9  0x4007134c in Tcl_VwaitObjCmd (clientData=0x0,
interp=0x804ec90, objc=2, 
    objv=0xbffff234) at ./../generic/tclEvent.c:1041
#10 0x4003e8f5 in TclEvalObjvInternal
(interp=0x804ec90, objc=2, objv=0xbffff234, 
    command=0x8069929 "vwait result\n\nthread::release
$thread\nthread::join $thread\n\nexit 0\n\n### end of
file\n\n", length=13, flags=0)
    at ./../generic/tclBasic.c:3087
#11 0x4003f644 in Tcl_EvalEx (interp=0x804ec90, 
    script=0x8069848 "package require Tcl 8.4\npackage
require Thread 2.5\nset other 0\nif { $other } {\n   
package require tcltest 2.2\n}\n\n\nset thread
[thread::create -joinable]\n\nthread::send -async
$thread {\n    set ans {}\n "..., numBytes=310, 
    flags=0) at ./../generic/tclBasic.c:3682
#12 0x4009a5fc in Tcl_FSEvalFile (interp=0x804ec90,
pathPtr=0x806e0e8)
    at ./../generic/tclIOUtil.c:1749
#13 0x400a3c53 in Tcl_Main (argc=1, argv=0xbffff758, 
    appInitProc=0x80486c8 <Tcl_AppInit>) at
./../generic/tclMain.c:292
#14 0x080486bc in main (argc=2, argv=0xbffff754) at
./../unix/tclAppInit.c:90

tcl_platform(byteOrder) = littleEndian
tcl_platform(machine)   = i686
tcl_platform(os)        = Linux
tcl_platform(osVersion) = 2.4.22
tcl_platform(platform)  = unix
tcl_platform(threaded)  = 1
tcl_platform(user)      = marco
tcl_platform(wordSize)  = 4

I think that the problem is ThreadClbkSetVar()
(threadCmd.c): it
does the (TCL_OK != code) test while it should do
(TCL_ERROR == code).
User Comments:
vasiljevic added on 2004-05-05 16:08:34:
Logged In: YES 
user_id=95086

I think I already solved this in the 2.6 version. 
It is still not released but CVS HEAD is in the  
very good state. Please make a checkout, compile 
and try again.

vasiljevic added on 2004-06-21 13:45:22:
Logged In: YES 
user_id=95086

Solved in 2.6 which is to be released in 2-4 weeks.