From 47109e8be05c52fd33c2a67b1929ed3c19479787 Mon Sep 17 00:00:00 2001 From: dkf Date: Fri, 14 Dec 2001 10:32:47 +0000 Subject: * win/tclWinNotify.c (Tcl_FinalizeNotifier): Stop Tcl on Windows from crashing when shutdown from a non-Tcl thread. Fixes Bug #217982 [orig. 5804] reported by Hugh Vu and Gene Leache. I'm not convinced that the shutdown process is right even with this, but it was definitely wrong without... --- ChangeLog | 8 ++++++++ win/tclWinNotify.c | 16 +++++++++++++++- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 022b795..f843806 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2001-12-14 Donal K. Fellows + + * win/tclWinNotify.c (Tcl_FinalizeNotifier): Stop Tcl on Windows + from crashing when shutdown from a non-Tcl thread. Fixes Bug + #217982 [orig. 5804] reported by Hugh Vu and Gene Leache. I'm + not convinced that the shutdown process is right even with this, + but it was definitely wrong without... + 2001-12-13 Andreas Kupries * win/tclWinSock.c (TcpGetOptionProc): Fix for tcl bug item diff --git a/win/tclWinNotify.c b/win/tclWinNotify.c index d788086..5df1e8d 100644 --- a/win/tclWinNotify.c +++ b/win/tclWinNotify.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinNotify.c,v 1.9 2001/11/21 02:36:21 hobbs Exp $ + * RCS: @(#) $Id: tclWinNotify.c,v 1.10 2001/12/14 10:32:47 dkf Exp $ */ #include "tclWinInt.h" @@ -147,6 +147,20 @@ Tcl_FinalizeNotifier(clientData) { ThreadSpecificData *tsdPtr = (ThreadSpecificData *) clientData; + /* + * Only finalize the notifier if a notifier was installed in the + * current thread; there is a route in which this is not + * guaranteed to be true (when tclWin32Dll.c:DllMain() is called + * with the flag DLL_PROCESS_DETACH by the OS, which could be + * doing so from a thread that's never previously been involved + * with Tcl, e.g. the task manager) so this check is important. + * + * Fixes Bug #217982 reported by Hugh Vu and Gene Leache. + */ + if (tsdPtr == NULL) { + return; + } + DeleteCriticalSection(&tsdPtr->crit); CloseHandle(tsdPtr->event); -- cgit v0.12