Tcl Source Code

View Ticket
Login
Ticket UUID: 419449
Title: TclInExit returns wrong value.
Type: Bug Version: None
Submitter: vincentdarley Created on: 2001-04-27 11:05:28
Subsystem: 02. Event Loops Assigned To: hobbs
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2002-11-07 09:12:18
Resolution: Fixed Closed By: mdejong
    Closed on: 2002-11-07 02:12:18
Description:
If TclInExit is called very late in the finalize 
sequence, the thread specific data has been freed 
already, and TclInExit returns the wrong value (and in 
fact re-initialises the thread specific data).  The 
patch below fixes this problem.

TclKit can, under some circumstances, run into this 
bug.


$ diff -r -C3 tcl8.4/generic/tclEvent.c 
tcl8.4v/generic/tclEvent.c
*** tcl8.4/generic/tclEvent.c   Sat Mar 31 08:57:31 
2001
--- tcl8.4v/generic/tclEvent.c  Thu Feb  1 15:21:47 
2001
***************
*** 935,942 ****
  int
  TclInExit()
  {
!     ThreadSpecificData *tsdPtr = TCL_TSD_INIT
(&dataKey);
!     return tsdPtr->inExit;
  }
  ^L
  /*
--- 935,946 ----
  int
  TclInExit()
  {
!     ThreadSpecificData *tsdPtr = TclThreadDataKeyGet
(&dataKey);
!     if (tsdPtr == NULL) {
!       return inFinalize;
!     } else {
!       return tsdPtr->inExit;
!     }
  }
  ^L
  /*
User Comments: mdejong added on 2002-11-07 09:12:18:

File Added - 34814: patch

Logged In: YES 
user_id=90858

Jeff mentioned that this patch was related to the problem I
was having.
I ended up solving it by splitting the normal and per thread
exit
status up into two functions so that one could tell when Tcl
was finalizing itself in a callback registered by
Tcl_CreateExitHandler.
The patch I checked in is attached.

hobbs added on 2001-09-11 08:28:37:
Logged In: YES 
user_id=72656

fixed in core-8-3-1-branch and 8.4a4cvs head.

vincentdarley added on 2001-09-10 23:39:36:

File Added - 10604: tclEvent.patch

Logged In: YES 
user_id=32170

Ok, a patch is attached.

dgp added on 2001-04-28 07:34:36:
Logged In: YES 
user_id=80530

Can you attach the patch, rather than include it
in the comment?

Attachments: