Skip to content
Tcl Source Code History Of Ticket f9800d52bd
Login

History Of Ticket f9800d52bd

Artifacts Associated With Ticket f9800d52bd

  1. Ticket change [2debc3b81e] (rid 194899) by pooryorick on 2021-06-19 21:36:06:

    1. assignee initialized to: "nobody"
    2. closer initialized to: "nobody"
    3. cmimetype initialized to: "text/x-fossil-wiki"
    4. comment initialized to:
      At least as of [07f12cf7209a23fa3], core-8-branch, the script below aborts.
      The trouble begins with the C stack being busy because c2 has been called from
      with <code>vwait</code>, which is not yet NRE-enabled.  Although the error
      message talks about tailcall, it is really about <code>yieldto</code>, which
      calls <code>TclSetTailcall</code>.
      
      
      <code><verbatim>
      proc main_coro {} {
      	set done [catch {
      		coroutine c1 p0 
      		yieldto c1
      		coroutine c2 p1
      		after 0 [list [namespace which c2]]
      		vwait forever 
      	} cres copts]
      }
      
      proc p0 {} {
      	yield
      	::tailcall main
      }
      
      proc p1 {} {
      	yield
      	set this [info coroutine]
      	set script [list ::yieldto [list $this]]
      	yieldto try $script on error {cres copt} "
      		puts \[list uh-oh \$cres]
      		[list $this]
      	"
      	set script [list ::yieldto $this]
      	yieldto ::try $script
      }
      
      
      coroutine main main_coro
      </verbatim></code>
      
      <b>Output:</b>
      
      <verbatim>
      uh-oh {cannot yield: C stack busy}
      tailcall cannot find the right splicing spot: should not happen!
      Aborted (core dumped)
      </verbatim>
      
    5. is_private initialized to: "0"
    6. login: "pooryorick"
    7. priority initialized to: "5 Medium"
    8. resolution initialized to: "None"
    9. severity initialized to: "Critical"
    10. status initialized to: "Open"
    11. submitter initialized to: "pooryorick"
    12. subsystem initialized to: "- New Builtin Commands"
    13. title initialized to:
      vwait is not NRE-enabled, and yieldto cnot find the right splicing spot
      
    14. type initialized to: "Bug"
  2. Ticket change [543bd21881] (rid 194900) by pooryorick on 2021-06-19 21:36:49:

    1. login: "pooryorick"
    2. mimetype: "text/plain"
    3. title changed to:
      vwait is not NRE-enabled, and yieldto cannot find the right splicing spot
      
  3. Ticket change [6ae4458216] (rid 194917) by pooryorick on 2021-06-20 06:41:00:

    1. icomment: "sebres noted this issue in [cc592ec70de012df]."
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  4. Ticket change [76cd3d8c7d] (rid 194919) by dkf on 2021-06-20 07:45:06:

    1. icomment:
      Well, this shouldn't crash. It probably should be an error though; I can't comprehend any way to make <code>vwait</code> itself be anything other than NRE-unaware.
      
    2. login: "dkf"
    3. mimetype: "text/html"
  5. Ticket change [e067049ad3] (rid 194922) by pooryorick on 2021-06-20 18:28:46:

    1. icomment:
      Here is a slightly smaller script to reproduce the issue:
      
      <code><verbatim>
      proc p0 {} {
      	yield
      	yieldto c1
      	after 0 c2 
      	vwait forever
      }
      
      proc p1 {} {
      	yield
      	tailcall c0
      }
      
      proc p2 {} {
      	yield
      	after 0 [list [info coroutine]]
      	yieldto try {yieldto c1} on error {} c1
      	yieldto try [list yieldto c1]
      }
      coroutine c0 p0
      coroutine c1 p1
      coroutine c2 p2
      after 0 [list [namespace which c0]]
      vwait forever
      </verbatim></code>
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  6. Ticket change [f539153892] (rid 194930) by pooryorick on 2021-06-20 23:10:13:

    1. icomment:
      The problem is that <code>TclSetTailcall<code> splices the command to be
      yielded to into the right place, but when
      <code>TclNRCoroutineActivateCallback</code> decides the C stack is busy, it
      doesn't go back and undo the splice.  At that point, the splicing spot is
      already taken and any other attempt to yieldto produces the error, "tailcall
      cannot find the right splicing spot: should not happen!".  From here on out,
      that command that hasn't been unspliced behaves like a tailcall:  When the
      coroutine ends that command takes its place.  Tailcall itself doesn't have the
      same problem as yieldto because tailcall uses a slightly different mechanism to
      register the tailcall.  The solution is to undo that splice of the pending
      command if yieldto can't proceed.
      
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  7. Ticket change [a5883ef8c0] (rid 194931) by pooryorick on 2021-06-20 23:10:45:

    1. icomment: "Fixed in [c75d4c3be05d5e91]."
    2. login: "pooryorick"
    3. mimetype: "text/x-fossil-wiki"
  8. Ticket change [25e0e0bbb4] (rid 194932) by pooryorick on 2021-06-20 23:11:15:

    1. assignee changed to: "pooryorick"
    2. login: "pooryorick"
    3. mimetype: "text/plain"
    4. resolution changed to: "Fixed"
    5. status changed to: "Pending"
  9. Ticket change [824dd98358] (rid 194994) by jan.nijtmans on 2021-06-21 14:54:08:

    1. icomment:
      'Fix' reverted from core-8-branch, because it broke the build.
      
      See: [https://github.com/tcltk/tcl/runs/2872891537?check_suite_focus=true]
      
      <pre>
      coroutine.test
      Test file error: cannot yield: C stack busy
          while executing
      "yieldto c1"
          ("try" body line 1)
          invoked from within
      "c2"
          ("after" script)
      cannot yield: C stack busy
          while executing
      "yieldto c1"
          ("try" body line 1)
          ("after" script)
      </pre>
      
    2. login: "jan.nijtmans"
    3. mimetype: "text/x-fossil-wiki"
    4. resolution changed to: "None"
    5. status changed to: "Open"
  10. Ticket change [0e22c12b3b] (rid 195028) by jan.nijtmans on 2021-06-23 13:01:38:

    1. closedate changed to: "2459389.04281083"
    2. closer changed to: "jan.nijtmans"
    3. icomment:
      Merged (again) to core-8-branch (and trunk). Appears to work now.
      
      Thanks for the fix, and the updated testcase!
      
    4. login: "jan.nijtmans"
    5. mimetype: "text/x-fossil-wiki"
    6. resolution changed to: "Fixed"
    7. status changed to: "Closed"