#5228 re-resolution gets wrong target

current: 8.6.0
open
5
2013-04-16
2013-04-09
Don Porter
No

Here's the real bug I've been striving to demonstrate,
recording mismatches with exec tracing capability
along the way.

oo::object create foo
oo::objdefine foo {
method target {} {puts Hit!}
forward bar my target
method bump {} {
set ns [info object namespace ::foo]
rename ${ns}::my ${ns}::
rename ${ns}:: ${ns}::my
}
}
proc harness {} {
foo target
foo bar
}
proc handle {cmd args} {
foo bump
}
trace add execution harness enterstep handle
proc my {method} {
puts Missed!
}
harness

Output:

Hit!
Missed!

The re-resolution of "my" happens in the wrong
context.

Comparing with the machinery in [tailcall], I think
this one has a simple fix.

Discussion

  • Don Porter

    Don Porter - 2013-04-09

    Branch bug-3610404 has the one-liner fix.

     
  • Donal K. Fellows

    Flushing that cache in that way shouldn't cause that. Ick.

     
  • Donal K. Fellows

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

    And the new tests cause a panic under 8.5!

    Tcl_ListObjAppendElement called with shared object

    That bumps it right to highest priority.

     
  • Donal K. Fellows

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

    And that appears to be a bug in Tcl 8.5.

     
  • Donal K. Fellows

    The 8.5 crash seems to be an "impossible" case. Memory corruption suspected.

     
  • Donal K. Fellows

    And I can't see where it is happening at all. :-(

     
  • Donal K. Fellows

    (There's a list inside AppendPrintfToObjVA that should only have a single reference to it and which should — in this case — end up with four elements in it, and which is never passed externally, but it is ending up with two references and 5 elements, at which point Tcl_ListObjAppendElement gets rightfully upset. Real WTF moment.)

     
  • Don Porter

    Don Porter - 2013-04-16
    • priority: 9 --> 5
     
  • Don Porter

    Don Porter - 2013-04-16

    Looks like the problem is refCount management
    of the commandPtr in the TclEvalObjvInternal() routine.

     
  • Don Porter

    Don Porter - 2013-04-16

    Here's the patch:

    Index: generic/tclBasic.c

    --- generic/tclBasic.c
    +++ generic/tclBasic.c
    @@ -3650,10 +3650,11 @@

    if (cmdEpoch != newEpoch) {
    checkTraces = 0;
    if (commandPtr) {
    Tcl_DecrRefCount(commandPtr);
    + commandPtr = NULL;
    }
    goto reparseBecauseOfTraces;
    }
    }

     
  • Don Porter

    Don Porter - 2013-04-16

    committed to core-8-5-branch