#3163 namespace delete in rename trace causes bus error

obsolete: 8.5a3

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 ""


  • miguel sofer

    miguel sofer - 2005-06-14
    • labels: --> 21. [namespace]
    • assigned_to: nobody --> dkf
  • Donal K. Fellows

    Logged In: YES

    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.

  • Donal K. Fellows

    • priority: 5 --> 9
  • Donal K. Fellows

    Logged In: YES

    Fixed in HEAD.

  • Donal K. Fellows

    • status: open --> closed-fixed