Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2008-03-12
00:24 • Closed ticket [1911919fff]: namespace delete trouble with unset variable traces<... artifact: cec871d9c6 user: msofer
2008-03-11
21:53 • Ticket [1911919fff]: 1 change artifact: 5e31149357 user: juliannoble
14:52 • New ticket [1911919fff]. artifact: 0934149b03 user: juliannoble

namespace delete trouble with unset variable traces

Closed / Fixed1911919fffffffffffffffffffffffffffffffffCreated 19 years agoUpdated 19 years ago
Descriptionplain2008-03-11 14:52:25
When a trace handler command for a variable trace on an unset operation reinstalls the same unset trace - this causes trouble when the corresponding namespace is deleted.
The handler is called multiple times - causing large (multi-second) delays in the script.

This behaviour didn't occur in  Tcl 8.5a7 or 8.4  but does occur in 8.5b1, 8.5.0 & 8.5.2.b1 


namespace eval refs { 
} 
for {set i 0} {$i < 10} {incr i} { 
        set refname ::refs::$i 
        trace add variable $refname {read write unset} [list ::tracehandler] 
} 

proc ::tracehandler {args} { 
        #lassign [lrange $args end-2 end] vref vidx op 
        foreach {vref vidx op} [lrange $args end-2 end] {break} 
        switch -- $op { 
                write { 
                        error "write failed. This reference cannot be treated as a 
variable" 
                } 
                unset { 
                        trace add variable $vref {read write unset} [concat ::tracehandler 
$args] 


                        #according to man page - errors in unset traces are ignored - so 
this is not useful: 
                        #error "cannot unset. This reference cannot be treated as a 
variable" 
                } 
                read { 
                        error "read failed. This reference cannot be treated as a variable" 
                } 
        } 
        return 
} 
puts stdout "===>[time {namespace delete ::refs}]<==="
juliannoble Ticket [1911919fff]: 1 change [History diff]2008-03-11 21:53:57
msoferplain2008-03-12 00:24:46
Logged In: YES 
user_id=148712
Originator: NO

The problem was caused by unset traces during namespace delete NOT being called with a fully qualified name.
Log in (anonymous is fine) to add a comment.