Skip to content
Tcl Source Code View Ticket
Login

View Ticket

init.tcl not found in thread interpreter

Closed / Wont Fix1505810fffffffffffffffffffffffffffffffffCreated 20 years agoUpdated 20 years ago
Descriptionplain2006-06-14 06:39:31
We are using the thread extension in combination with
an application specific tcl_library path (in other
words, in this installation *only* the tcl_library
variable knows where to find a usable "init.tcl"). With
thread-2.6.3, when we spawn a new thread using
"thread::create" that new thread does not find the
"init.tcl" and is thus slightly handicapped; we
currently have to manually do the following to get a
functional thread:

thread::send $tid [list set tcl_library $tcl_library]
thread::send $tid {
   source [file join $tcl_library init.tcl]
} 

This feels like a hack that better ought to be fixed in
the thread package itself. 

Inspecting the code one finds that threadCmd.c executes

    interp = Tcl_CreateInterp();
    result = Tcl_Init(interp);

in NewThread(clientData). It seems that "result" is
currently not used, so any failure at that stage
remains unnoticed. I would suggest to always initialize
the thread's tcl_library with the parent's tcl_library
before calling Tcl_Init().
dgpplain2006-06-14 22:28:44
Logged In: YES 
user_id=80530


set ::env(TCL_LIBRARY) $::tcl_library

in the master interp should be
a work-around for this issue.
vasiljevicplain2006-09-06 20:49:00
Logged In: YES 
user_id=95086

I believe that this is out of the scope of the 
threading extension code. At the point of ignoring
the result of Tcl_Init()... Yes, I know it is ignored.
At that point I was pretty unsure what to do as the 
thread ID has already been reported to the user, so
I could'nt just exited the new thread. I do still have
this weird thing on my todo list...

I will close this ticket with "Won't Fix" but will
keep an eye on somehow improving the code to signalize
error if the Tcl_Init does not finish properly.
Log in (anonymous is fine) to add a comment.