Artifacts Associated With Ticket 2390819
Ticket change [7772631986] (rid 89776) by dgp on 2008-12-04 22:07:45:
- assignee initialized to: "dgp"
- cmimetype initialized to: "text/plain"
- comment initialized to:
% proc foo1 {} { catch {return -code error zoom} err return [list $err zam] } % proc foo2 {} { catch { return -code error zoom } err return [list $err zam] } [foo1] and [foo2] are the same except for whitespace, and as expected, they produce the same results: % foo1 zoom zam % foo2 zoom zam Next create same routines again, with new names, bar1 and bar2: % proc bar1 {} { catch {return -code error zoom} err return [list $err zam] } % proc bar2 {} { catch { return -code error zoom } err return [list $err zam] } This time, before compiling and running, add a leave trace on [catch] : % trace add execution catch leave {puts zing! ;#} and try again: % bar1 zing! zoom zam % bar2 zing! zoom WTF?!?!? - foundin initialized to: "obsolete: 8.4.19"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "dgp"
- subsystem initialized to: "46. Traces"
- title initialized to: "[catch] leave trace mystery"
- type initialized to: "Bug"
Ticket change [304959f533] (rid 93219) by dgp on 2008-12-05 05:09:52:
- icomment:
Then try the whole thing in 8.5.5: <... cut to the chase ...> % bar1 zing! zoom zam % bar2 zing! 2
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [8eaabbfc7c] (rid 120151) by dgp on 2013-01-08 02:04:37:
- priority changed to: "9 Immediate"
Ticket change [b41338335d] (rid 124962) by dgp on 2013-03-20 03:18:40:
- icomment:
The trouble here is that the trailing " ;# " in the execution trace handler doesn't do what the programmer expected. It doesn't cause all arguments passed to the handler to be ignored. Instead it causes the leading substring in it up to the first newline to be ignored only. Then it starts up again with the rest, which is the command [return -code error zoom]. Now that that's being eval'd outside the catch, it bubbles up the stack. At least that's the explanation for the 8.4 results. Ugly complex version of pilot error.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [78b1ad0e47] (rid 90003) by dgp on 2013-03-20 03:22:13:
- icomment:
Corrected demo works fine: % info patch 8.4.19 % proc report args {puts zing!} % trace add execution catch leave report % proc bar2 {} { catch { return -code error zoom } err return [list $err zam] } % bar2 zing! zoom zam - login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [1aba4ce45c] (rid 123031) by dgp on 2013-03-20 03:24:59:
- icomment:
Corrected code also works as expected in 8.5 and 8.6. Remaining mystery is why the pilot error version fails differently in 8.5+. Suspect it's something not right in how [catch] gets compiled and executed as bytecode.
- login: "dgp"
- mimetype: "text/plain"
- username: "dgp"
- icomment:
Ticket change [38d07a3870] (rid 112275) by dgp on 2013-03-21 11:42:12:
- closedate changed to: "2013-03-21T04:42:12"
- closer changed to: "dgp"
- icomment:
allow_comments - 1 Re-reported as 3608676 without so much noise and confusion.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Duplicate"
- status changed to: "Closed"
- username: "dgp"