Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2005-06-14
20:46 • Closed ticket [1220058fff]: namespace delete in rename trace causes bus error</i... artifact: 6a8f6d4612 user: dkf
20:44 • Ticket [1220058fff]: 5 changes artifact: aea80c65b8 user: dkf
07:52 • Ticket [1220058fff]: 2 changes artifact: b89dfd0391 user: msofer
00:44 • New ticket [1220058fff]. artifact: ce3e84d80d user: duquette

namespace delete in rename trace causes bus error

Closed / Fixed1220058fffffffffffffffffffffffffffffffffCreated 21 years agoUpdated 21 years ago
Descriptionplain2005-06-14 00:44:26
Problem Behavior: Tcl halts with a bus error

The following code creates an ensemble command using
"namespace ensemble", and then renames the ensemble to "".
A rename trace fires which deletes the namespace, which is when 
Tcl terminates with a bus error.  The code is a much simplified
version of something I found while working on Snit 2.0.  Note that in 
Snit 1.0 the only difference is that the command is a standard proc, 
not a namespace ensemble, and there's no error.

namespace eval ::foo:: {
    namespace ensemble create -command ::bar
}

trace add command ::bar delete DeleteTrace

proc DeleteTrace {old new op} {
    puts "DeleteTrace [list $old $new $op]"

    trace remove command ::bar delete DeleteTrace
    
    # If this line is removed, there's no bus error,
    rename $old ""

    # This next line causes the bus error
    namespace delete ::foo::
}

rename ::bar ""
msofer Ticket [1220058fff]: 2 changes [History diff]2005-06-14 07:52:30
dkfplain2005-06-14 20:44:37
Logged In: YES 
user_id=79902

Ooh, this is an evil one. It turns out that it is now
possible for the same command token to hit
Tcl_DeleteCommandFromToken *three* times, which causes Bad
Things To Happen.
dkfplain2005-06-14 20:46:20
Logged In: YES 
user_id=79902

Fixed in HEAD.
Log in (anonymous is fine) to add a comment.