diff options
author | davygrvy <davygrvy@noemail.net> | 2003-12-21 21:58:43 (GMT) |
---|---|---|
committer | davygrvy <davygrvy@noemail.net> | 2003-12-21 21:58:43 (GMT) |
commit | 863eb8e9a3d655ea0e37d0f61f6e0a827a9c4697 (patch) | |
tree | e5ca544dc0d78e5204a8b71d3ffb9d3544263ef5 /win | |
parent | 97ee715979876fc3f5cd7ced2b99699e8dc0e09d (diff) | |
download | tcl-863eb8e9a3d655ea0e37d0f61f6e0a827a9c4697.zip tcl-863eb8e9a3d655ea0e37d0f61f6e0a827a9c4697.tar.gz tcl-863eb8e9a3d655ea0e37d0f61f6e0a827a9c4697.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]
FossilOrigin-Name: 1c41033288de7f1528c1ea6f59c8cc56d79f5e8e
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; } |