Skip to content
Tcl Source Code History Of Ticket 132fad6fde1b40e8
Login

History Of Ticket 132fad6fde1b40e8

Artifacts Associated With Ticket 132fad6fde1b40e8

  1. Ticket change [32e0f6c4eb] (rid 139551) by hypnotoad on 2014-09-02 19:41:46:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. comment initialized to:
      The latest Tcl release in trunk now locks the process whenever "exit" is called. (Locked defined as, Windows throws up an error saying the process has stopped responding)
      
      My build procedure:
      cd $LOCALSANDBOX/tcl/win
      make distclean
      fossil update core-8-6-2
      ./configure --prefix=c:/odie
      make all
      ./tclsh86.exe exit.tcl
      (Exits properly)
      
      make distclean
      fossil update trunk
      ./configure --prefix=c:/odie
      make all
      ./tclsh86.exe exit.tcl
      (Process hangs)
      
      Exit.tcl contains the following line:
      exit 0
      
      When I gdb ./tclsh86.exe
      run exit.tcl
      
      The stack trace I receive is:
      $ gdb ./tclsh86.exe
      GNU gdb (GDB) 7.6.1
      Copyright (C) 2013 Free Software Foundation, Inc.
      License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
      and "show warranty" for details.
      This GDB was configured as "mingw32".
      For bug reporting instructions, please see:
      <http://www.gnu.org/software/gdb/bugs/>...
      Reading symbols from c:\odie\sandbox\tcl\win\tclsh86.exe...done.
      (gdb) run exit.tcl
      Starting program: c:\odie\sandbox\tcl\win/./tclsh86.exe exit.tcl
      [New Thread 2868.0xa08]
      warning: HEAP[tclsh86.exe]:
      warning: Invalid address specified to RtlFreeHeap( 004C0000, 00752D60 )
      
      
      Program received signal SIGTRAP, Trace/breakpoint trap.
      0x77140575 in ntdll!RtlpNtEnumerateSubKey ()
         from C:\Windows\system32\ntdll.dll
      (gdb) bt
      #0  0x77140575 in ntdll!RtlpNtEnumerateSubKey ()
         from C:\Windows\system32\ntdll.dll
      #1  0x77102aba in ntdll!RtlUlonglongByteSwap ()
         from C:\Windows\system32\ntdll.dll
      #2  0x00752d58 in ?? ()
      #3  0x771415cf in ntdll!RtlpNtEnumerateSubKey ()
         from C:\Windows\system32\ntdll.dll
      #4  0x770fac29 in ntdll!RtlUlonglongByteSwap ()
         from C:\Windows\system32\ntdll.dll
      #5  0x004c0000 in ?? ()
      #6  0x770a34a2 in ntdll!RtlImageNtHeader () from C:\Windows\system32\ntdll.dll
      #7  0x769f14ad in KERNEL32!HeapFree () from C:\Windows\syswow64\kernel32.dll
      #8  0x6d5ffdcf in TclFreeAllocCache () from c:\odie\sandbox\tcl\win\tcl86.dll
      #9  0x6d62c855 in TclpFreeAllocCache () from c:\odie\sandbox\tcl\win\tcl86.dll
      #10 0x6d600654 in TclFinalizeThreadAllocThread ()
         from c:\odie\sandbox\tcl\win\tcl86.dll
      #11 0x6d593bab in Tcl_Exit () from c:\odie\sandbox\tcl\win\tcl86.dll
      #12 0x6d523a36 in Tcl_ExitObjCmd () from c:\odie\sandbox\tcl\win\tcl86.dll
      #13 0x6d510480 in Dispatch () from c:\odie\sandbox\tcl\win\tcl86.dll
      #14 0x6d5151f5 in TclNRRunCallbacks () from c:\odie\sandbox\tcl\win\tcl86.dll
      #15 0x6d51721f in TclEvalEx () from c:\odie\sandbox\tcl\win\tcl86.dll
      #16 0x6d5c3a43 in Tcl_FSEvalFileEx () from c:\odie\sandbox\tcl\win\tcl86.dll
      #17 0x6d5ca7b3 in Tcl_MainExW () from c:\odie\sandbox\tcl\win\tcl86.dll
      #18 0x004039fa in main ()
      
    5. foundin initialized to: "trunk"
    6. is_private initialized to: "0"
    7. login: "hypnotoad"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "5846a328c39e4967aaeb56d4e03d3e783e2dd1b8"
    10. resolution initialized to: "None"
    11. severity initialized to: "Severe"
    12. status initialized to: "Open"
    13. submitter initialized to: "hypnotoad"
    14. subsystem initialized to: "04. Async Events"
    15. title initialized to: "exit 0 - Hangs under Windows"
    16. type initialized to: "Bug"
  2. Ticket change [de7f071b2c] (rid 139552) by ferrieux on 2014-09-02 19:51:27:

    1. icomment:
      Though Sean identified the critical commit as 4ca7fe7cf209ccf83375421d45464ff9a5f90a29 (use of TclpSysFree et al), which could be fixed, I don't think TclFinalizeThreadAllocThread is useful at exit time.
      
      Following trivial patch removes it in that case:
      
      Index: generic/tclEvent.c
      ==================================================================
      --- generic/tclEvent.c
      +++ generic/tclEvent.c
      @@ -1297,22 +1297,24 @@
       	TclFinalizeIOSubsystem();
       	TclFinalizeNotifier();
       	TclFinalizeAsync();
       	TclFinalizeThreadObjects();
           }
      +    if (!TclInExit()) { /* useless if we are facing exit() */
       
      -    /*
      -     * Blow away all thread local storage blocks.
      -     *
      -     * Note that Tcl API allows creation of threads which do not use any Tcl
      -     * interp or other Tcl subsytems. Those threads might, however, use thread
      -     * local storage, so we must unconditionally finalize it.
      -     *
      -     * Fix [Bug #571002]
      -     */
      -
      -    TclFinalizeThreadData();
      +	/*
      +	 * Blow away all thread local storage blocks.
      +	 *
      +	 * Note that Tcl API allows creation of threads which do not use any Tcl
      +	 * interp or other Tcl subsytems. Those threads might, however, use thread
      +	 * local storage, so we must unconditionally finalize it.
      +	 *
      +	 * Fix [Bug #571002]
      +	 */
      +	
      +	TclFinalizeThreadData();
      +    }
       }
       
      
       /*
        *----------------------------------------------------------------------
        *
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  3. Ticket change [a06fc719e5] (rid 139553) by hypnotoad on 2014-09-02 19:58:05:

    1. icomment:
      I have applied ferrieux's patch, and the hanging has stopped.
      
    2. login: "hypnotoad"
    3. mimetype: "text/plain"
    4. username: "hypnotoad"
  4. Ticket change [9277491f1f] (rid 139559) by ferrieux on 2014-09-02 20:20:29:

    1. icomment:
      Polished patch, guarantees that in the TCL_FINALIZE_ON_EXIT=1 case, things happen exactly as before (that his, hanging at the same place).
      
      This allows to keep most users happy, and let interested parties debug commit 4ca7fe7cf209ccf83375421d45464ff9a5f90a29 by setting the var.
      
      
      Index: generic/tclEvent.c
      ==================================================================
      --- generic/tclEvent.c
      +++ generic/tclEvent.c
      @@ -1297,22 +1297,24 @@
       	TclFinalizeIOSubsystem();
       	TclFinalizeNotifier();
       	TclFinalizeAsync();
       	TclFinalizeThreadObjects();
           }
      +    if (TclFullFinalizationRequested()) { /* useless if we are facing a quick-exit */
       
      -    /*
      -     * Blow away all thread local storage blocks.
      -     *
      -     * Note that Tcl API allows creation of threads which do not use any Tcl
      -     * interp or other Tcl subsytems. Those threads might, however, use thread
      -     * local storage, so we must unconditionally finalize it.
      -     *
      -     * Fix [Bug #571002]
      -     */
      -
      -    TclFinalizeThreadData();
      +	/*
      +	 * Blow away all thread local storage blocks.
      +	 *
      +	 * Note that Tcl API allows creation of threads which do not use any Tcl
      +	 * interp or other Tcl subsytems. Those threads might, however, use thread
      +	 * local storage, so we must unconditionally finalize it.
      +	 *
      +	 * Fix [Bug #571002]
      +	 */
      +	
      +	TclFinalizeThreadData();
      +    }
       }
       
      
       /*
        *----------------------------------------------------------------------
        *
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  5. Ticket change [13dab4355c] (rid 139578) by ferrieux on 2014-09-02 22:06:50:

    1. icomment:
      Just committed to trunk (a) the addition of test cases for hang-on-exit, in both quick and full-finalize exit cases; (b) the patch below, to avoid useless freeing in the quick case.
      
      The root cause of the present bug is now simply exerciseable by seeing "exec-1.2" fail.
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  6. Ticket change [f6464dfe02] (rid 139579) by ferrieux on 2014-09-02 22:08:17:

    1. assignee changed to: "dgp"
    2. icomment:
      Assigned to dgp, as the root issue is now confined to commit 4ca7fe7c.
      
    3. login: "ferrieux"
    4. mimetype: "text/plain"
  7. Ticket change [72a398d7ac] (rid 139596) by dgp on 2014-09-03 12:51:41:

    1. icomment:
      Without the ability to use the new tests
      and see exit-1.2 fail ( as I expect it is
      currently failing on the trunk on Windows ),
      there's nothing I can do or learn here directly.
      
      That leaves me no course of action other than to
      just revert the checkin I made that caused the
      trouble in the first place.
      
      Seems there's a learning opportunity here to try
      to comprehend why TclpSysAlloc() is not a proper
      replacement for malloc() here, and gaining that
      understanding, put it into comments where malloc()
      is being used so some future developer doesn't
      just repeat the same error.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  8. Ticket change [f6fa5a3b00] (rid 139600) by dgp on 2014-09-03 15:39:08:

    1. icomment:
      Yeah, the "learning opportunity" is to be sure
      to change calloc calls as well when changing
      malloc.  :P
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  9. Ticket change [253cc57b39] (rid 139604) by apnadkarni on 2014-09-03 15:56:32:

    1. icomment:
      Fixed by changing GetCache to use TclpSysAlloc+memset instead of calloc. Heap corruption was caused by calloc'ed memory being freed using HeapFree (via TclpSysFree)
      
    2. login: "apnadkarni"
    3. mimetype: "text/plain"
  10. Ticket change [61641d62dc] (rid 139720) by dgp on 2014-09-08 14:25:25:

    1. assignee changed to: "ferrieux"
    2. icomment:
      I think there may be a problem with the new addition to
      the "quick exit".
      
      One thing that TclFinalizeThreadData() does is to make
      it so that the next call to 
      
          TclThreadDataKeyGet(&dataKey)
      
      returns NULL.  This has importance because it makes
      TclInThreadExit() return 0.  If we're not going to
      call TclFinalizeThreadData(), it seems we're then
      compelled to 
      
          tsdPtr->inExit = 0;
      
      on the way out.
      
    3. login: "dgp"
    4. mimetype: "text/plain"
  11. Ticket change [ca33900dfd] (rid 139744) by ferrieux on 2014-09-08 22:57:08:

    1. icomment:
      Fix committed. The TclFinalizeThreadData function is now refined to skip the useless pure-memory-cleanup step *only* when (1) we are in exit and (2) the quick-exit mode is wanted.
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
  12. Ticket change [58fc8323f0] (rid 140212) by dgp on 2014-10-09 15:47:40:

    1. closedate changed to: "2456940.15811279"
    2. closer changed to: "dgp"
    3. login: "dgp"
    4. mimetype: "text/plain"
    5. resolution changed to: "Fixed"
    6. status changed to: "Closed"