Skip to content
Tcl Source Code View Ticket
Login

View Ticket

duplicate trace with namespace exported proc

Openfc88534d38e4136a22e58c8b7e8cd257773ae8efCreated 7 years agoUpdated 47 days ago
Descriptionplain2019-11-29 08:55:31
In the following test case, the procedure test is always sent a duplicate trace if that proc was exported out of the namespace, vs. when called with the full name. 

namespace eval Counter {
    namespace export test 
    proc test {} {
       return
    }
}

proc tracer {args} {
	puts "tracer: `$args`"
}

proc main {args} {
	test
	puts ""
	::Counter::test
}

namespace import Counter::test 

trace add execution main enterstep tracer
main
Referenced by1
  • c8c14f3e58Fix [fc88534d38]: step and interpreter traces saw an imported command twice, because InvokeImportedNRCmd() re-dispatched to the real command through TclNREvalObjv(). The new internal flag TCL_EVAL_NO_INTERP_TRACES skips the interpreter traces for that re-dispatch; execution traces on the real command still fire. check-in2026-10-17 06:37:04
serhiy.storchakawiki2026-10-17 06:37:55

Regression since 8.6 (8.5 traces the call once): InvokeImportedNRCmd() re-dispatches to the real command through TclNREvalObjv(), which runs the step and interpreter traces a second time. Proposed fix in branch imported-cmd-step-traces: an internal flag skips the interpreter traces for that re-dispatch; execution traces on the real command still fire. Tests trace-41.1 and trace-41.2.

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