diff options
author | davygrvy <davygrvy@pobox.com> | 2003-12-21 21:58:43 (GMT) |
---|---|---|
committer | davygrvy <davygrvy@pobox.com> | 2003-12-21 21:58:43 (GMT) |
commit | f23cd539456a29d518593237b36c33fdf9357da2 (patch) | |
tree | e5ca544dc0d78e5204a8b71d3ffb9d3544263ef5 /win | |
parent | b6816410ac218247688be307500a6471f1b0ba21 (diff) | |
download | tcl-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]
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWin32Dll.c | 17 |
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; } |