summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2003-12-21 21:58:43 (GMT)
committerdavygrvy <davygrvy@pobox.com>2003-12-21 21:58:43 (GMT)
commitf23cd539456a29d518593237b36c33fdf9357da2 (patch)
treee5ca544dc0d78e5204a8b71d3ffb9d3544263ef5
parentb6816410ac218247688be307500a6471f1b0ba21 (diff)
downloadtcl-f23cd539456a29d518593237b36c33fdf9357da2.zip
tcl-f23cd539456a29d518593237b36c33fdf9357da2.tar.gz
tcl-f23cd539456a29d518593237b36c33fdf9357da2.tar.bz2
Structured Exception Handling added around Tcl_Finalize called from
DllMain's DLL_PROCESS_DETACH. We can't 100% assured that Tcl is being unloaded by the OS in a stable condition and we need to protect the exit handlers should the stack be in a hosed state. AT&T style assembly for SEH under MinGW has not been added yet. This is a first part change for [Patch 858493]
-rw-r--r--win/tclWin32Dll.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/win/tclWin32Dll.c b/win/tclWin32Dll.c
index dc497f4..b6e1c06 100644
--- a/win/tclWin32Dll.c
+++ b/win/tclWin32Dll.c
@@ -9,7 +9,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclWin32Dll.c,v 1.28 2003/10/13 16:48:07 vincentdarley Exp $
+ * RCS: @(#) $Id: tclWin32Dll.c,v 1.29 2003/12/21 21:58:43 davygrvy Exp $
*/
#include "tclWinInt.h"
@@ -232,6 +232,9 @@ DllEntryPoint(hInst, reason, reserved)
*
* Side effects:
* Establishes 32-to-16 bit thunk and initializes sockets library.
+ * This might call some sycronization functions, but MSDN
+ * documentation states: "Waiting on synchronization objects in
+ * DllMain can cause a deadlock."
*
*----------------------------------------------------------------------
*/
@@ -247,8 +250,16 @@ DllMain(hInst, reason, reserved)
return TRUE;
case DLL_PROCESS_DETACH:
- if (hInst == hInstance) {
- Tcl_Finalize();
+ /*
+ * Protect the call to Tcl_Finalize. The OS could be unloading
+ * us from an exception handler and the state of the stack might
+ * be unstable.
+ */
+
+ __try {
+ Tcl_Finalize();
+ } __except (EXCEPTION_EXECUTE_HANDLER) {
+ /* empty handler body. */
}
break;
}