Skip to content
Tcl Source Code History Of Ticket 35a839cba8
Login

History Of Ticket 35a839cba8

Artifacts Associated With Ticket 35a839cba8

  1. Ticket change [2c3bc9ddd2] (rid 137582) by anonymous on 2014-04-14 16:38:04:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      Initialize Tcl and then call Tcl_Finalize().
      Now try to re-initialize Tcl, with Tcl_FindExecutable()
      This gives "TclInitSubsystems called while exiting" followed by an abort().
      
      This used to work prior to Tcl/Tk 8.6.
      
      Looking at the code, my guess is that this is related to the variable "inExit" in tclEvent.c (not in 8.5.15). Its comment says "This variable is set to 1 when Tcl_Exit is called" and it is never reset to zero.
      
      In 8.5.15, there is a similar variable "inFinalize" (gone in 8.6.1) with the comment "This variable is set to 1 when Tcl_Finalize is called, and at the end of its work, it is reset to 0.".
      
      Note the difference, the new variable "inExit" is never reset to 0.
      
      The backtrace says:
      0   libsystem_kernel.dylib        	0x00007fff91445ce2 __pthread_kill + 10
      1   libsystem_c.dylib             	0x00007fff8ec8a7d2 pthread_kill + 95
      2   libsystem_c.dylib             	0x00007fff8ec7ba7a abort + 143
      3   Tcl                           	0x0000000107f88c92 Tcl_PanicVA + 449
      4   Tcl                           	0x0000000107f88d34 Tcl_Panic + 162
      5   Tcl                           	0x0000000107f50927 TclInitSubsystems + 30
      6   Tcl                           	0x0000000107f47de3 Tcl_FindExecutable + 17
      
    5. foundin initialized to: "8.6.1"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "703c0a7e584f2f45023961b4a76843affe777033"
    10. resolution initialized to: "None"
    11. severity initialized to: "Important"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "50. Embedding Support"
    15. title initialized to: "Can not reinitialize Tcl after Tcl_Finalize()"
    16. type initialized to: "Bug"
  2. Ticket change [25a5fead91] (rid 138950) by dgp on 2014-07-23 13:50:59:

    1. assignee changed to: "ferrieux"
    2. icomment:
      ferrieux, I think you were involved with the
      finalization reforms of Tcl 8.6.  Can you give
      this a look?
      
      Could be a simple fix of a simple bug, or it could
      be a chance to record here why things changed in
      this way.
      
    3. login: "dgp"
    4. mimetype: "text/plain"
  3. Ticket change [ce36c9958a] (rid 139377) by ferrieux on 2014-08-25 22:19:58:

    1. icomment:
      Naive one-liner below just resets the flag at the end of Tcl_Finalize.
      Test suite ok even with TCL_FINALIZE_ON_EXIT=1, but that's hardly a
      proof of anything, since I guess no test does this (finalize and start
      over). Maybe you have the proper wrench at hand ?
      
      Index: generic/tclEvent.c
      ==================================================================
      --- generic/tclEvent.c
      +++ generic/tclEvent.c
      @@ -1245,10 +1245,15 @@
      
           TclFinalizeMemorySubsystem();
      
         alreadyFinalized:
           TclFinalizeLock();
      +
      +    /*
      +     *  In case someone wants to start over, permit it.
      +     */
      +    inExit = 0;
       }
      
      
       /*
        *----------------------------------------------------------------------
        *
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  4. Ticket change [a0c5d0f932] (rid 139378) by dgp on 2014-08-26 02:24:42:

    1. icomment:
      That suggests "safe" but doesn't demonstrate "effective".
      
      I'd like a demo that fails before and passes after the patch,
      (aka fails in 8.6 but works in 8.5) and so far I'm failing to get that.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  5. Ticket change [01fd11a41f] (rid 139379) by dgp on 2014-08-26 11:58:20:

    1. icomment:
      In my own attempts to test, it appears that
      reinitialize after finalization has been failing
      since
      
      http://core.tcl.tk/tcl/info/be83fe62c8
      
      I don't see any evidence that it ever worked
      in a stable Tcl 8.5.* release.
      
      It would be great to fix this, but I don't
      have high hopes.  My impression is that folks
      have given up on getting Tcl_Finalize() right,
      to the point where they have taken big steps to
      avoid calling it at all in Tcl 8.6.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  6. Ticket change [78fe1ee912] (rid 139380) by ferrieux on 2014-08-26 13:23:57:

    1. icomment:
      I do confirm that the net result of the "Bug 2001201 exit reform" is to avoid calling Finalize in the normal exit path; but the reason is more subtle than "it's broken and I can't be bothered to fix it". Rather, it is the sum of two things:
      
       - exit() is really the fastest way of getting out, because it implies (a) bulk memory freeing (the mappings just disappear, without  crawling whatever the userland thinks its heap contains) and (b) bulletproof release of kernel resources (like fds, mutexes, etc). The OOP habit of recursively calling the Destructor of every single living form in the universe is a suboptimal way of exiting when there is no compulsory app-level cleanup to do.
      
       - multithread finalization can lead to deadlocks, and there is no way to avoid them with certainty, short of exit() itself.
      
      Note the "reform" only says that [exit] will shun Finalize() (unless the TCL_FINALIZE_ON_EXIT env var is set to 1); it says nothing about what embedders do. And it did not sabotage the Finalize() function itself ;)
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  7. Ticket change [12457f914e] (rid 141535) by bdrewery on 2015-04-10 21:42:54:

    1. icomment:
      Ping? I've hit this in a library I am working on that reinitializes TCL.
      
    2. login: "bdrewery"
    3. mimetype: "text/plain"
  8. Ticket change [c710646bb8] (rid 141722) by dgp on 2015-05-11 19:00:49:

    1. icomment:
      
      bdrewery, can you supply the requested demo then?
      
      We don't want to just blindly patch.
      We'd rather have a short demo program that fails before
      and succeeds after the patch to demonstrate the bug and
      the fix.
      
      Also useful would be an identification of prior releases of
      Tcl that were not broken in the way that is giving you
      trouble.  So far, those claims have not been able to be
      reproduced.
      
      Thanks.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  9. Ticket change [fde5d7559a] (rid 141741) by mistachkin on 2015-05-14 04:47:23:

    1. icomment:
      Having also worked on finalization in the past, I certainly think the inExit flag
      needs to be reset.
      
      In my testing with Eagle on Windows (i.e. when it repeatedly loads and unloads
      the native Tcl library), I do not encounter any issues when only dealing with
      Tcl itself (i.e. no Tk).  I *think* this is due to me completely unloading the
      library from memory after calling Tcl_Finalize.
      
    2. login: "mistachkin"
    3. mimetype: "text/plain"