Skip to content
Tcl Source Code View Ticket
Login

View Ticket

TclInExit returns wrong value.

Closed / Fixed419449ffffffffffffffffffffffffffffffffffCreated 26 years agoUpdated 24 years ago
Descriptionplain2001-04-27 11:05:28
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
  /*
dgpplain2001-04-28 07:34:36
Logged In: YES 
user_id=80530

Can you attach the patch, rather than include it
in the comment?
andreas_kupries Ticket [419449ffff]: 2 changes [History diff]2001-09-07 04:06:57
vincentdarleyplain2001-09-10 23:39:36
File Added - 10604: tclEvent.patch

Logged In: YES 
user_id=32170

Ok, a patch is attached.
hobbsplain2001-09-11 08:28:37
Logged In: YES 
user_id=72656

fixed in core-8-3-1-branch and 8.4a4cvs head.
mdejongplain2002-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.
Log in (anonymous is fine) to add a comment.

Attachments: