Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-05-23
11:35 • Closed ticket [3610393fff]: forwards clash with execution traces plus 6 othe... artifact: 98c53bf181 user: dkf
2018-04-06
16:37 • Ticket [3610393fff]: 3 changes artifact: 2e608d90cc user: dgp
2014-09-14
18:16 • Ticket [3610393fff]: 3 changes artifact: 65f34387cd user: dgp
16:37 • Ticket [3610393fff]: 4 changes artifact: f57a5c961b user: dkf
2013-08-21
09:41 • Ticket [3610393fff]: 8 changes artifact: b860c9acbf user: dkf
2013-04-10
01:59 • Ticket [3610393fff]: 5 changes artifact: 18c9989a1a user: dgp
01:50 • Ticket [3610393fff]: 5 changes artifact: f257f4535b user: dkf
00:40 • Ticket [3610393fff]: 4 changes artifact: 763a6139b4 user: dgp
00:38 • Ticket [3610393fff]: 4 changes artifact: 9e1baefcf7 user: dgp
2013-04-09
17:12 • New ticket [3610393fff]. artifact: bb8ec40ddd user: dgp

forwards clash with execution traces

Closed / Duplicate3610393fffffffffffffffffffffffffffffffffCreated 14 years agoUpdated 3 years ago
Descriptionplain2013-04-09 17:12:08
oo::object create foo
oo::objdefine foo {
    method target {} {puts Hit!}
    forward bar my target
}
proc harness {} {
    foo target
    foo bar
}
proc handle {cmd args} {
    puts "Command [lindex $cmd 0] resolves to:"
    puts "\t'[uplevel 1 [list ::namespace which -command [lindex $cmd 0]]]'"
    puts "\t\tResolved at level [uplevel 1 {info level}]"
}
trace add execution harness enterstep handle
harness


Output:

Command foo resolves to:
        '::foo'
                Resolved at level 1
Command puts resolves to:
        '::puts'
                Resolved at level 2
Hit!
Command foo resolves to:
        '::foo'
                Resolved at level 1
Command my resolves to:
        ''
                Resolved at level 1
Command puts resolves to:
        '::puts'
                Resolved at level 2
Hit!


The problem is that [my] is an execution-trace-able
command, but the context in which it is executed
does not match the expectations of execution trace
handlers.  The CallFrame establishing the namespace
context for command resolution is missing.
dgpplain2013-04-10 00:38:45
The simple-minded fix -- put in the missing push/pop of
a stack frame -- makes the oo part of the test suite *very*
unhappy.
dgpplain2013-04-10 00:40:10
Alternative approach might be to declare
that forwards are special in some way, and
ought to be invisible to execution tracing,
and that's the real bug to fix.

Would want to check how ensemble and
alias redirection behave on that matter.
dkfplain2013-04-10 01:50:42
The bug is in the implementation of the specific execution trace; it is assuming that it can resolve the command simply. This is not necessarily true of any command that is invoked via TclNREvalObjv, as that interface allows the supply of the resolved command. Pushing an extra frame just to make your traces happy is very expensive for everything else (and likely to run into all sorts of problems with the extra frame to pass over in [uplevel]/[upvar]).

Very tempted to close as a Wont Fix. It's certainly not a high priority to tinker with.
dgpplain2013-04-10 01:59:06
Potential defects in the TclNREvalObjv interface
is exactly the issue I'm investigating.
dkfwiki2013-08-21 09:41:04

I would like this fixed, but don't know what to do about it.

dkfhtml2014-09-14 16:37:00

Sorry to drop this back onto you, but I've no idea what to do about it.

dgpplain2014-09-14 18:16:18
I expect that most or all of the answer will come in the fix for

http://core.tcl.tk/tcl/tktview?name=3610400
dgpplain2018-04-06 16:37:21
ping
dkfwiki2024-05-23 11:35:23

Closing in favour of [3610400] which should resolve this once we know how to do so.

The base issue is that the trace is assuming that the caller frame is the resolution context, and that's not true with forwards or tailcalls. It probably also isn't true with aliases in some cases.

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