#3783 Error in generic/tclVar.c TclDeleteNamespaceVars()

obsolete: 8.4.14
closed-invalid
miguel sofer
5
2007-09-07
2007-09-07
Anonymous
No

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.

Discussion

  • miguel sofer
    miguel sofer
    2007-09-07

    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.

     
  • miguel sofer
    miguel sofer
    2007-09-07

    • status: open --> closed-invalid