|
2016-08-22
| ||
| 07:04 | • Closed ticket [f23d040b9b]: application hangs in TclInitNotifier using TCL 8.5.1... artifact: 3759d339e4 user: jan.nijtmans | |
|
2016-06-07
| ||
| 06:37 | • Closed ticket [159a3e1dab]: Creating Tcl_Interp from two different threads ends ... artifact: 009c0e37c6 user: oehhar | |
|
2016-06-06
| ||
| 19:27 | • Ticket [159a3e1dab]: 3 changes artifact: 4b3c2892db user: jpo38 | |
|
2016-05-17
| ||
| 14:00 | • Ticket [159a3e1dab]: 3 changes artifact: 4787320aae user: dgp | |
|
2016-05-14
| ||
| 08:31 | • Ticket [159a3e1dab]: 3 changes artifact: 97ce7eb55d user: jpo38 | |
|
2016-05-03
| ||
| 12:56 | • Pending ticket [159a3e1dab]. artifact: 77e3041e3e user: dgp | |
| 06:27 | • New ticket [159a3e1dab]. artifact: 706a6aee14 user: jpo38 | |
Creating Tcl_Interp from two different threads ends up in an infinite loop
I can't create two interpreters from two different threads. The following code ends up in an infinite loop:
void runScript()
{
Tcl_Interp* pInterp = Tcl_CreateInterp();
Tcl_DeleteInterp( pInterp );
}
int main( int argc, char* argv[] )
{
Tcl_FindExecutable(NULL);
#include "tcl.h"
#include <boost/thread.hpp>
boost::thread thrd1( runScript );
thrd1.join();
boost::thread thrd2( runScript );
thrd2.join();
return 1;
}
Inifinite loop occures here:
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!
}
Adding:
if ( tsdPtr != NULL && tsdPtr->nextPtr == tsdPtr )
{
tsdPtr = NULL;
break;
}
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)
TCL_THREADS=1 is the means by which Tcl is compiled to support multi-threaded use. From what you've posted, I strongly suspect that's the problem here. If you continue to have trouble with a --enable-threads build of Tcl, please post again.
@dgp Can you point me to the doc explaining how to do that? Especially where to find compatible pthread version and have it be found by build system?
I don't understand what you are asking. I build only with the unix subdirectory toolchain. In that build system, the --enable-threads option to configure causes Tcl to be built supporting multi-threaded operations under the "apartment model". This is the default setting in releases Tcl 8.6.0 and higher.
@dgp:TCL_THREADS was disabled because I compiled on windows using a CMake Lists.txt file I found on the web: this one was actually written for Linux and disabled thread support because it was unable to find pthread on my machine. I finally compiled Tcl libraries using the scripts provided threading is enabled by default and the infinite loop is gone! Thanks for your help!