Overview
| Artifact ID: | 1877f2ad506940faccdad93bd90fc4c6f5363ba5 |
|---|---|
| Ticket: | 673714ffffffffffffffffffffffffffffffffff
Tcl_DeleteEvents() bug when deleting last event in queue |
| User & Date: | nobody on 2003-01-24 00:27:45 |
Changes
- assignee changed to: "kennykb"
- cmimetype changed to: "text/plain"
- comment changed to:
Hello Support, tclNotify.c : Tcl_DeleteEvents() removes events from the event queue. If the event deleted is the last event in the queue, the tsdPtr->lastEventPtr is left pointing at evPtr which gets freed. This leaves lastEventPtr pointing to freed memory which causes unpredictable behavior. I've changed the code so that lastEventPtr (and markEventPtr) get fixed up correctly in all cases. New code is included below. Platform: All Tested on Solaris 5.6 and Linux 7.1 Tested with Tcl 8.3.4, but same problem exists in source code is in 8.4.1. Regards, Michael Webb Model Technology Inc. (503)526-1660 [email protected] New Code for Tcl_DeleteEvents(): void Tcl_DeleteEvents(proc, clientData) Tcl_EventDeleteProc *proc; /* The procedure to call. */ ClientData clientData; /* type-specific data. */ { Tcl_Event *evPtr, *prevPtr, *hold; ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); Tcl_MutexLock(&(tsdPtr->queueMutex)); for (prevPtr = (Tcl_Event *) NULL, evPtr = tsdPtr->firstEventPtr; evPtr != (Tcl_Event *) NULL; ) { if ((*proc) (evPtr, clientData) == 1) { if (tsdPtr->firstEventPtr == evPtr) { tsdPtr->firstEventPtr = evPtr->nextPtr; } else { prevPtr->nextPtr = evPtr->nextPtr; } if (evPtr->nextPtr == (Tcl_Event *) NULL) { tsdPtr->lastEventPtr = prevPtr; } if (tsdPtr->markerEventPtr == evPtr) { tsdPtr->markerEventPtr = prevPtr; } hold = evPtr; evPtr = evPtr->nextPtr; ckfree((char *) hold); } else { prevPtr = evPtr; evPtr = evPtr->nextPtr; } } Tcl_MutexUnlock(&(tsdPtr->queueMutex)); }
- foundin changed to: "obsolete: 8.4.1"
- priority changed to: "5 Medium"
- resolution changed to: "None"
- status changed to: "Open"
- submitter changed to: "nobody"
- subsystem changed to: "01. Notifier"
- title changed to:
Tcl_DeleteEvents() bug when deleting last event in queue
- type changed to: "Bug"