Skip to content
Tcl Source Code History Of Ticket d87cb18205
Login

History Of Ticket d87cb18205

Artifacts Associated With Ticket d87cb18205

  1. Ticket change [2b9746e8d4] (rid 141399) by anonymous on 2015-03-19 01:56:51:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/plain"
    4. 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!
      
    5. foundin initialized to: "8.6.1 and later"
    6. is_private initialized to: "0"
    7. login: "anonymous"
    8. priority initialized to: "5 Medium"
    9. private_contact initialized to: "cb02a4a25e8da92f2790bc307bf01ef24ce6053e"
    10. resolution initialized to: "None"
    11. severity initialized to: "Minor"
    12. status initialized to: "Open"
    13. submitter initialized to: "anonymous"
    14. subsystem initialized to: "21. [namespace]"
    15. title initialized to:
      inconsisency in behaviour of tailcall from (builtin) namespace ensembles
      
    16. type initialized to: "Bug"
  2. Ticket change [55ee1f94bb] (rid 141400) by anonymous on 2015-03-19 02:03:54:

    1. 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!
      
    2. login: "anonymous"
    3. mimetype: "text/plain"
  3. Ticket change [39b5cf855e] (rid 141408) by pooryorick on 2015-03-19 13:31:08:

    1. 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!
      
    2. login: "pooryorick"
    3. mimetype: "text/plain"
  4. Ticket change [78787c0062] (rid 141409) by dgp on 2015-03-19 20:02:20:

    1. icomment:
      
      How in the world does the last case reverse
      the order of output?!
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  5. Ticket change [f022f66972] (rid 141410) by dgp on 2015-03-19 20:07:35:

    1. 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.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  6. Ticket change [85422869b9] (rid 141411) by dgp on 2015-03-19 20:10:31:

    1. 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
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  7. Ticket change [83e2a61811] (rid 141415) by dgp on 2015-03-20 20:22:37:

    1. icomment:
      
      I suspect the
      
              TclSkipTailcall(interp);
      
      within the INST_INVOKE_REPLACE implementation
      may be the skunk at this particular garden party.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  8. Ticket change [e5cb52f291] (rid 141416) by dgp on 2015-03-20 20:31:02:

    1. 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.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  9. Ticket change [87c65af6b2] (rid 141417) by dgp on 2015-03-20 20:57:05:

    1. 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.
      
    2. login: "dgp"
    3. mimetype: "text/plain"
  10. Ticket change [31b8434c9e] (rid 141421) by msofer on 2015-03-20 23:16:53:

    1. 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]
      
    2. login: "msofer"
    3. mimetype: "text/plain"
  11. Ticket change [01d04163b1] (rid 141422) by dgp on 2015-03-21 00:34:34:

    1. assignee changed to: "dgp"
    2. closedate changed to: "2457102.52400721"
    3. closer changed to: "dgp"
    4. icomment:
      
      Fix and test committed.
      
    5. login: "dgp"
    6. mimetype: "text/plain"
    7. resolution changed to: "Fixed"
    8. status changed to: "Closed"
  12. Ticket change [965aefbe87] (rid 141427) by msofer on 2015-03-21 15:07:34:

    1. assignee changed to: "msofer"
    2. closer changed to: "nobody"
    3. icomment:
      Reopening, as the fix caused a violation of the constant-space property of tailcalls. See the new test tailcall-0.5.1
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "None"
    7. status changed to: "Open"
  13. Ticket change [60dc13f71d] (rid 141441) by msofer on 2015-03-23 00:34:52:

    1. closedate changed to: "2457104.52421332"
    2. closer changed to: "msofer"
    3. icomment:
      Definitive fix committed: we needed TclMarkTailcall rather than TclSkipTailcall.
      
    4. login: "msofer"
    5. mimetype: "text/plain"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"