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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.