Skip to content
Tcl Source Code View Ticket
Login

View Ticket

Error in generic/tclVar.c TclDeleteNamespaceVars()

Closed / Invalid1790435fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2007-09-07 20:30:38
There is an error in the TclDeleteNamespaceVars() subroutine for version 8.4.14.  At line 4618:

         hPtr = Tcl_FirstHashEntry(tablePtr, &search)) {   

should be changed to

         hPtr = Tcl_NextHashEntry(&search)) {


  otherwise an infinite loop occurs.
msoferplain2007-09-08 03:45:01
Logged In: YES 
user_id=148712
Originator: NO

Not an error, per design.

First, no infinite loop: each time you go through the body one variable is deleted from the table by Tcl_DeleteHashEntry, so (assuming no new variables are created) eventually there are none left.

Second, per design: delete traces on variables may create or delete other variables. By starting the search anew with Tcl_FirstHashEntry you insure that (a) you always get a valid hPtr (as opposed to one that was deleted from under your feet), and (b) no new hPtr appeared behind your back (at a part of the hashtable that you thought you were done visiting).

This is implemented correctly, but is indeed problematic and can lead to infinite loops (every deleted variable creates another one via a trace): see bug #1740700

The precise semantics and event ordering on namespace deletion requires revisiting.
Log in (anonymous is fine) to add a comment.