|
2014-10-09
| ||
| 15:47 | • Closed ticket [132fad6fde]: exit 0 - Hangs under Windows plus 5 other change... artifact: 58fc8323f0 user: dgp | |
|
2014-09-08
| ||
| 22:57 | • Ticket [132fad6fde]: 3 changes artifact: ca33900dfd user: ferrieux | |
| 14:25 | • Ticket [132fad6fde]: 4 changes artifact: 61641d62dc user: dgp | |
|
2014-09-03
| ||
| 15:56 | • Ticket [132fad6fde]: 3 changes artifact: 253cc57b39 user: apnadkarni | |
| 15:48 | [132fad6fde]. Fixed GetCache to use TclpSysAlloc+memset instead of calloc. Now consistent with tclWi... check-in: da203cbda6 user: ashok tags: trunk | |
| 15:39 | • Ticket [132fad6fde] exit 0 - Hangs under Windows status still Open with 3 ot... artifact: f6fa5a3b00 user: dgp | |
| 12:51 | • Ticket [132fad6fde]: 3 changes artifact: 72a398d7ac user: dgp | |
|
2014-09-02
| ||
| 22:08 | • Ticket [132fad6fde]: 4 changes artifact: f6464dfe02 user: ferrieux | |
| 22:06 | • Ticket [132fad6fde]: 3 changes artifact: 13dab4355c user: ferrieux | |
| 20:20 | • Ticket [132fad6fde]: 3 changes artifact: 9277491f1f user: ferrieux | |
| 19:58 | • Ticket [132fad6fde]: 4 changes artifact: a06fc719e5 user: hypnotoad | |
| 19:51 | • Ticket [132fad6fde]: 3 changes artifact: de7f071b2c user: ferrieux | |
| 19:41 | • New ticket [132fad6fde]. artifact: 32e0f6c4eb user: hypnotoad | |
exit 0 - Hangs under Windows
Closed / Fixed132fad6fde1b40e8f1e2081884313a98fdd1d4ccCreated 12 years agoUpdated 12 years ago
Descriptionplain2014-09-02 19:41:46
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 ()
Referenced by1
da203cbda6[132fad6fde]. Fixed GetCache to use TclpSysAlloc+memset instead of calloc. Now consistent with tclWinThrd.c which no longer uses malloc in its TclpSysAlloc implementation. check-in2014-09-03 15:48:56
ferrieuxplain2014-09-02 19:51:27
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();
+ }
}
/*
*----------------------------------------------------------------------
*
hypnotoadplain2014-09-02 19:58:05
I have applied ferrieux's patch, and the hanging has stopped.
ferrieuxplain2014-09-02 20:20:29
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();
+ }
}
/*
*----------------------------------------------------------------------
*
ferrieuxplain2014-09-02 22:06:50
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.
ferrieuxplain2014-09-02 22:08:17
Assigned to dgp, as the root issue is now confined to commit 4ca7fe7c.
dgpplain2014-09-03 12:51:41
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.
dgpplain2014-09-03 15:39:08
Yeah, the "learning opportunity" is to be sure to change calloc calls as well when changing malloc. :P
apnadkarniplain2014-09-03 15:56:32
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)
dgpplain2014-09-08 14:25:25
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.
ferrieuxplain2014-09-08 22:57:08
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.
dgp Closed ticket [132fad6fde].
[History diff]2014-10-09 15:47:40
Log in (anonymous is fine) to add a comment.