Overview
| Artifact ID: | 706a6aee141fdbfad1a42da39bcd714b15754952 |
|---|---|
| Ticket: | 159a3e1dab1142775a8e1ccee3e09323d9e290de
Creating Tcl_Interp from two different threads ends up in an infinite loop |
| User & Date: | jpo38 on 2016-05-03 06:27:30 |
Changes
- assignee changed to: "nobody"
- closer changed to: "nobody"
- cmimetype changed to: "text/x-fossil-wiki"
- comment changed to:
I'm embedding Tcl interpreter library (8.6.5) in a C++ application. I can't create two interpreters from two different threads. The following code ends up in an infinite loop: <code> #include "tcl.h" #include <boost/thread.hpp> void runScript() { Tcl_Interp* pInterp = Tcl_CreateInterp(); Tcl_DeleteInterp( pInterp ); } int main( int argc, char* argv[] ) { Tcl_FindExecutable(NULL); boost::thread thrd1( runScript ); thrd1.join(); boost::thread thrd2( runScript ); thrd2.join(); return 1; } </code> Inifinite loop occures here: <code> void TclInitNotifier(void) { ThreadSpecificData *tsdPtr; Tcl_ThreadId threadId = Tcl_GetCurrentThread(); Tcl_MutexLock(&listLock); for (tsdPtr = firstNotifierPtr; tsdPtr && tsdPtr->threadId != threadId; tsdPtr = tsdPtr->nextPtr) { /* Empty loop body. */ // this loop never ends! } </code> Adding: <code> if ( tsdPtr != NULL && tsdPtr->nextPtr == tsdPtr ) { tsdPtr = NULL; break; } </code> within the loop apparently fixes the issue. Note that I compiled Tcl with a CMake script, I noticed that TCL_THREADS is not set (not sure it's related or not) - foundin changed to: "8.6.5"
- is_private changed to: "0"
- login: "jpo38"
- priority changed to: "5 Medium"
- private_contact changed to: "54d7c7073766af3c0b23c08dde393222d793580a"
- resolution changed to: "None"
- severity changed to: "Minor"
- status changed to: "Open"
- submitter changed to: "jpo38"
- subsystem changed to: "49. Threading"
- title changed to:
Creating Tcl_Interp from two different threads ends up in an infinite loop
- type changed to: "Bug"