Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: b0d446b8c920bc4e0383d05c714de7c471840ab243becbcce9e692866090d8b0
Ticket: cc592ec70de012dff030d61affb4b8d62da6cfb6
vwait not NRE-enabled: C stack busy
User & Date: sebres on 2018-04-16 10:02:31
Changes

  1. icomment:
    The problem is here not really the NRE-capability as is.
    So if vwait get compiled variant it could be interrupted within execute of compiled code. 
    But the question is why it should be - in your example the vwait should wait for variable "forever". But the execution of "yieldto c2" should interrupt the "normal" flow... And in this case either stop the vwait process? Or continue it after exit from c2 (weird for me)?
    
    To explain what do you expect, just try to rewrite it with "while", like this:
    
    <code><verbatim>
    set ::forever 1
    coroutine c2 ::apply {{} {
        yield
        puts [list exit from coroutine [info coroutine]]
    }}
     
    coroutine c1 ::apply [list {} {
        set c {
            puts [list in coroutine [info coroutine]]
            yieldto c2
        }
        while {$::forever} {
            if {$c ne ""} $c
            set c ""
        }
        puts [list exit from coroutine [info coroutine]]
    }]
    </verbatim></code>
    
    In above-mentioned example the flow is interrupted and endless wait is interrupted:
    
    <code><verbatim>
    in coroutine ::c1
    exit from coroutine ::c2
    </verbatim></code>
    Would it expected in your opinion?
    
    <hr/>
    Just as notice to me: another still worse example (producing segfault ATM):
    <code><verbatim>
    coroutine c2 ::apply {{} {
        yield
        puts [list interim in coroutine [info coroutine]]
        yieldto c1
        puts [list exit from coroutine [info coroutine]]
        set ::forever 1
    }}
     
    coroutine c1 ::apply [list {} {
        after 0 {
            puts [list in coroutine [info coroutine]]
            yieldto c2
        }
        after 1 {
            puts [list in coroutine [info coroutine]]
            yieldto c2
        }
        vwait ::forever
    }]
    </verbatim></code>
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"