From a85067c3276c504baded33ddeaab0f61f8dad6f1 Mon Sep 17 00:00:00 2001 From: vasiljevic Date: Sun, 27 Apr 2008 08:36:20 +0000 Subject: Also, panic early if we find out the wrong thread attempting to delete the async handler (common trap). As, only the one that created the handler is allowed to delete it. --- ChangeLog | 4 ++++ generic/tclAsync.c | 12 ++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index f799bf0..e9e38f1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,10 @@ to locate handler token fails. Happens when some other thread attempts to delete somebody else's token. + Also, panic early if we find out the wrong thread attempting + to delete the async handler (common trap). As, only the one + that created the handler is allowed to delete it. + 2008-04-24 Andreas Kupries * tests/ioCmd.test: Extended testsuite for reflected channel diff --git a/generic/tclAsync.c b/generic/tclAsync.c index 2fd4347..f57c456 100644 --- a/generic/tclAsync.c +++ b/generic/tclAsync.c @@ -11,7 +11,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclAsync.c,v 1.14 2008/04/26 11:53:24 vasiljevic Exp $ + * RCS: @(#) $Id: tclAsync.c,v 1.15 2008/04/27 08:36:20 vasiljevic Exp $ */ #include "tclInt.h" @@ -262,7 +262,7 @@ Tcl_AsyncInvoke( * Failure to locate the handler in current thread private list * of async handlers will result in panic; exception: the list * is already empty (potential trouble?). - * Consequently, threads should create and delete handlers + * Consequently, threads should create and delete handlers * themselves. I.e. a handler created by one should not be * deleted by some other thread. * @@ -278,6 +278,14 @@ Tcl_AsyncDelete( AsyncHandler *prevPtr, *thisPtr; /* + * Assure early handling of the constraint + */ + + if (asyncPtr->originThrdId != Tcl_GetCurrentThread()) { + panic("Tcl_AsyncDelete: async handler deleted by the wrong thread"); + } + + /* * If we come to this point when TSD's for the current * thread have already been garbage-collected, we are * in the _serious_ trouble. OTOH, we tolerate calling -- cgit v0.12