From b23d942a1e86ddee18c2309afd7fa7e9afa79ef8 Mon Sep 17 00:00:00 2001 From: mdejong Date: Wed, 19 Jan 2005 22:07:37 +0000 Subject: * win/tclWinChan.c (FileCloseProc): Invoke TclpCutFileChannel() to remove a FileInfo from the thread local list before deallocating it. This should have been done via an earlier call to Tcl_CutChannel, but I was running into a crash in the next call to Tcl_CutChannel during the IO finalization stage. --- ChangeLog | 12 +++++++++++- win/tclWinChan.c | 21 ++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 69c8b78..1abac3d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-01-19 Mo DeJong + + * win/tclWinChan.c (FileCloseProc): Invoke + TclpCutFileChannel() to remove a FileInfo from + the thread local list before deallocating it. + This should have been done via an earlier + call to Tcl_CutChannel, but I was running into + a crash in the next call to Tcl_CutChannel + during the IO finalization stage. + 2005-01-18 Kevin Kenny * library/tzdata/GMT+0: @@ -14,7 +24,7 @@ Routine update per Olson's tzdata2005c. Removed links to links (Greenwich in several aliases; Navajo; Acre). Updated Paraguayan DST rules and "best guess" at this year's Israeli rules. - + 2005-01-17 Vince Darley * generic/tclFileName.c: fix for glob failure on Windows shares diff --git a/win/tclWinChan.c b/win/tclWinChan.c index 7dd3dae..fb7a83d 100644 --- a/win/tclWinChan.c +++ b/win/tclWinChan.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: tclWinChan.c,v 1.37 2004/10/20 14:50:44 dkf Exp $ + * RCS: @(#) $Id: tclWinChan.c,v 1.38 2005/01/19 22:07:41 mdejong Exp $ */ #include "tclWinInt.h" @@ -395,6 +395,8 @@ FileCloseProc(instanceData, interp) Tcl_Interp *interp; /* Not used. */ { FileInfo *fileInfoPtr = (FileInfo *) instanceData; + FileInfo *infoPtr; + ThreadSpecificData *tsdPtr; int errorCode = 0; /* @@ -419,6 +421,23 @@ FileCloseProc(instanceData, interp) } } + /* + * See if this FileInfo* is still on the thread local list. + */ + tsdPtr = TCL_TSD_INIT(&dataKey); + for (infoPtr = tsdPtr->firstFilePtr; infoPtr != NULL; + infoPtr = infoPtr->nextPtr) { + if (infoPtr == fileInfoPtr) { + /* + * This channel exists on the thread local list. It should + * have been removed by an earlier call to TclpCutFileChannel, + * but do that now since just deallocating fileInfoPtr would + * leave an deallocated pointer on the thread local list. + */ + TclpCutFileChannel(fileInfoPtr->channel); + break; + } + } ckfree((char *)fileInfoPtr); return errorCode; } -- cgit v0.12