Skip to content
Tcl Source Code History Of Ticket 159a3e1dab114277
Login

History Of Ticket 159a3e1dab114277

Artifacts Associated With Ticket 159a3e1dab114277

  1. Ticket change [706a6aee14] (rid 146610) by jpo38 on 2016-05-03 06:27:30:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized 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)
      
    5. foundin initialized to: "8.6.5"
    6. is_private initialized to: "0"
    7. login: "jpo38"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "54d7c7073766af3c0b23c08dde393222d793580a"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "jpo38"
    14. subsystem initialized to: "49. Threading"
    15. title initialized to:
      Creating Tcl_Interp from two different threads ends up in an infinite loop
      
    16. type initialized to: "Bug"
  2. Ticket change [77e3041e3e] (rid 146611) by dgp on 2016-05-03 12:56:24:

    1. icomment:
      
      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.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
    4. resolution changed to: "Invalid"
    5. status changed to: "Pending"
  3. Ticket change [97ce7eb55d] (rid 146728) by jpo38 on 2016-05-14 08:31:42:

    1. icomment:
      @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?
      
    2. login: "jpo38"
    3. mimetype: "text/plain"
  4. Ticket change [4787320aae] (rid 146737) by dgp on 2016-05-17 14:00:58:

    1. icomment:
      
      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.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  5. Ticket change [4b3c2892db] (rid 146900) by jpo38 on 2016-06-06 19:27:43:

    1. icomment:
      @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!
      
    2. login: "jpo38"
    3. mimetype: "text/plain"
  6. Ticket change [009c0e37c6] (rid 146901) by oehhar on 2016-06-07 06:37:38:

    1. closedate changed to: "2457546.77613545"
    2. closer changed to: "oehhar"
    3. login: "oehhar"
    4. mimetype: "text/plain"
    5. status changed to: "Closed"