Tcl Source Code

View Ticket
Login
Ticket UUID: 1740700
Title: var deletion infinite loop
Type: Bug Version: obsolete: 8.5a7
Submitter: dgp Created on: 2007-06-21 03:17:04
Subsystem: 07. Variables Assigned To: msofer
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2007-09-24 09:20:03
Resolution: Fixed Closed By: sf-robot
    Closed on: 2007-09-24 02:20:03
Description:
noted in the chat:

infinite loop:
% proc foo {i args} {namespace eval ::a set [incr i] 1; trace add variable ::a::$i unset [list ::foo $i]}
% foo 0
% info vars a::*
::a::1
% namespace delete a
User Comments: sf-robot added on 2007-09-24 09:20:03:
Logged In: YES 
user_id=1312539
Originator: NO

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

dgp added on 2007-09-10 03:59:22:

File Added - 244864: undo.patch

Logged In: YES 
user_id=80530
Originator: YES


This bug is fixed on HEAD.

If it's decided this isn't really
a bug after all, attached patch
will restore this behavior.
File Added: undo.patch

msofer added on 2007-07-07 02:29:24:
Logged In: YES 
user_id=148712
Originator: NO

The algorithm for variable deletion on namespace death keeps unsetting variables (and running unset traces) until no more are left. It does make sure that a variable cannot revive *itself* (ie, #1746143 is not possible on namespace deletion), but makes otherwise no difference between variables that existed at the time of the [namespace delete] call and those that were created afterwards.

This does look like a bug to me - but I am not sure what the right behaviour would be. One radical solution would be to unhook the ns's variable table before starting to unset, replacing it with an empty one. After unsetting all variables in the main table, the second table would be deleted without running unset traces. Such a thing would change the semantics slightly: no pre-existing variable in this namespace is accessible while var unset traces are running. In contrast, today they may (or may not) be: variables are unset in table order (ie, more or less random), so some of them may still be accessible while others are already gone. Can't imagine much use for this.

Attachments: