Artifacts Associated With Ticket d87cb18205
Ticket change [2b9746e8d4] (rid 141399) by anonymous on 2015-03-19 01:56:51:
- assignee initialized to: "nobody"
- closer initialized to: "nobody"
- cmimetype initialized to: "text/plain"
- comment initialized to:
Using [tailcall] from a proc in a namespace ensemble's -map used to work as expected on 8.6.0. On 8.6.1 and later, something changed: # tailcall and uplevel identity: proc it {} { tailcall try { puts it:[::incr x] } } proc iu {} { uplevel 1 { puts iu:[::incr x] } } proc aa {} { it iu return $x } puts aa:[aa] ;# it:1 iu:2 aa:2 - as expected # now try in an ensemble: namespace eval ens { namespace ensemble create } namespace ensemble configure ens -map {threet threet threeu threeu} proc ab {} { it iu return $x } puts ab:[ab] ;# it:1 iu:2 ab:2 - as expected # now try with an existing ensemble: set map [namespace ensemble configure dict -map] dict set map it ::it dict set map iu ::iu namespace ensemble configure dict -map $map proc ac {} { dict it dict iu return $x } puts ac:[ac] ;# iu:1 it:2 ac: - not at all as expected! - foundin initialized to: "8.6.1 and later"
- is_private initialized to: "0"
- login: "anonymous"
- priority initialized to: "5 Medium"
- private_contact initialized to: "cb02a4a25e8da92f2790bc307bf01ef24ce6053e"
- resolution initialized to: "None"
- severity initialized to: "Minor"
- status initialized to: "Open"
- submitter initialized to: "anonymous"
- subsystem initialized to: "21. [namespace]"
- title initialized to:
inconsisency in behaviour of tailcall from (builtin) namespace ensembles
- type initialized to: "Bug"
Ticket change [55ee1f94bb] (rid 141400) by anonymous on 2015-03-19 02:03:54:
- comment changed to:
Using [tailcall] from a proc in a namespace ensemble's -map used to work as expected on 8.6.0. On 8.6.1 and later, something changed: # tailcall and uplevel identity: proc it {} { tailcall try { puts it:[::incr x] } } proc iu {} { uplevel 1 { puts iu:[::incr x] } } proc aa {} { it iu return $x } puts aa:[aa] ;# it:1 iu:2 aa:2 - as expected # now try in an ensemble: namespace eval ens { namespace ensemble create } namespace ensemble configure ens -map {it ::it ut ::ut} proc ab {} { it iu return $x } puts ab:[ab] ;# it:1 iu:2 ab:2 - as expected # now try with an existing ensemble: set map [namespace ensemble configure dict -map] dict set map it ::it dict set map iu ::iu namespace ensemble configure dict -map $map proc ac {} { dict it dict iu return $x } puts ac:[ac] ;# iu:1 it:1 ac: - not at all as expected! - login: "anonymous"
- mimetype: "text/plain"
- comment changed to:
Ticket change [39b5cf855e] (rid 141408) by pooryorick on 2015-03-19 13:31:08:
- icomment:
Here is the example, correcting what were likely a few typos/omissions. It illustrates the same unexpected behaviour: # tailcall and uplevel identity: proc it {} { tailcall try { puts it:[::incr x] } } proc iu {} { uplevel 1 { puts iu:[::incr x] } } proc aa {} { it iu return $x } puts aa:[aa] ;# it:1 iu:2 aa:2 - as expected # now try in an ensemble: namespace eval ens { namespace ensemble create } namespace ensemble configure ens -map {it ::it iu ::iu} proc ab {} { ens it ens iu return $x } puts ab:[ab] ;# it:1 iu:2 ab:2 - as expected # now try with an existing ensemble: set map [namespace ensemble configure dict -map] dict set map it ::it dict set map iu ::iu namespace ensemble configure dict -map $map proc ac {} { dict it dict iu return $x } puts ac:[ac] ;# iu:1 it:1 ac: - not at all as expected! - login: "pooryorick"
- mimetype: "text/plain"
- icomment:
Ticket change [78787c0062] (rid 141409) by dgp on 2015-03-19 20:02:20:
- icomment:
How in the world does the last case reverse the order of output?!
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [f022f66972] (rid 141410) by dgp on 2015-03-19 20:07:35:
- icomment:
Well, I was sure folks were just mis-pasting, but no, the order is truly reversed: % puts ac:[ac] iu:1 it:1 ac: Now consider the next case: % proc ad {} { set dict dict $dict it $dict iu return $x } % puts ad:[ad] it:1 iu:2 ad:2 So it becomes clear the fault in is the bytecode compiling of ensembles. - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [85422869b9] (rid 141411) by dgp on 2015-03-19 20:10:31:
- icomment:
Continuing... % tcl::unsupported::disassemble proc ac ByteCode 0x0x1941f50, refCt 1, epoch 18, interp 0x0x18bc670 (epoch 18) Source "\n dict it\n dict iu\n return "... Cmds 3, src 39, inst 48, litObjs 5, aux 0, stkDepth 3, code/src 0.00 Proc 0x0x18d0fa0, refCt 1, args 0, compiled locals 1 slot 0, scalar, "x" Commands 3: 1: pc 0-12, src 5-11 2: pc 13-34, src 17-23 3: pc 35-46, src 29-37 Command 1: "dict it"... (0) push1 0 # "dict" (2) push1 1 # "it" (4) push1 2 # "::it" (6) invokeReplace 2 2 (12) pop Command 2: "dict iu"... (13) startCommand +21 1 # next cmd at pc 34, 1 cmds start here (22) push1 0 # "dict" (24) push1 3 # "iu" (26) push1 4 # "::iu" (28) invokeReplace 2 2 (34) pop Command 3: "return $x"... (35) startCommand +12 1 # next cmd at pc 47, 1 cmds start here (44) loadScalar1 %v0 # var "x" (46) done (47) done % ac iu:1 it:2 % ac iu:1 it:3 - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [83e2a61811] (rid 141415) by dgp on 2015-03-20 20:22:37:
- icomment:
I suspect the TclSkipTailcall(interp); within the INST_INVOKE_REPLACE implementation may be the skunk at this particular garden party. - login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [e5cb52f291] (rid 141416) by dgp on 2015-03-20 20:31:02:
- icomment:
Yes. Comment that out and the demo script submitted behaves as one would expect. ....and then I ran the complete test suite with 0 failures, so if that call has an actual purpose, it's a purpose not demonstrated by any test.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [87c65af6b2] (rid 141417) by dgp on 2015-03-20 20:57:05:
- icomment:
I imagine the call is there anticipating trouble when the target of the ensemble redirect is itself the [tailcall] command, such as dict set map tc tailcall . But I'm not able to actually demonstrate that.
- login: "dgp"
- mimetype: "text/plain"
- icomment:
Ticket change [31b8434c9e] (rid 141421) by msofer on 2015-03-20 23:16:53:
- icomment:
TclSkipTailcall just means "when looking for a place to splice in the tailcall, do not do it here - skip this spot, look at the previous command". It is used so that tailcalling out of a redirector (alias, ensemble, etc) really empties the stack - go to the redirector, don't stay at the redirection target. If it is missing, the "bug" will be a resource leak in repeated tailcalls. Not sure if this is tested, but if it is it would only show when tested in a memdebug build - as the leak tests rely on [memory]
- login: "msofer"
- mimetype: "text/plain"
- icomment:
Ticket change [01d04163b1] (rid 141422) by dgp on 2015-03-21 00:34:34:
- assignee changed to: "dgp"
- closedate changed to: "2457102.52400721"
- closer changed to: "dgp"
- icomment:
Fix and test committed.
- login: "dgp"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"
Ticket change [965aefbe87] (rid 141427) by msofer on 2015-03-21 15:07:34:
- assignee changed to: "msofer"
- closer changed to: "nobody"
- icomment:
Reopening, as the fix caused a violation of the constant-space property of tailcalls. See the new test tailcall-0.5.1
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "None"
- status changed to: "Open"
Ticket change [60dc13f71d] (rid 141441) by msofer on 2015-03-23 00:34:52:
- closedate changed to: "2457104.52421332"
- closer changed to: "msofer"
- icomment:
Definitive fix committed: we needed TclMarkTailcall rather than TclSkipTailcall.
- login: "msofer"
- mimetype: "text/plain"
- resolution changed to: "Fixed"
- status changed to: "Closed"