| Ticket UUID: | cc592ec70de012dff030d61affb4b8d62da6cfb6 | ||
| Title: | vwait not NRE-enabled: C stack busy | ||
| Type: | Bug | Created on: | 2018-04-14 09:28:50 |
| Submitter: | pooryorick | Assigned to: | nobody |
| Subsystem: | - New Builtin Commands | Severity: | Severe |
| Priority: | 5 Medium | Last modified: | 2026-10-17 08:47:42 |
| Status: | Open | Closed by: | nobody |
| Resolution: | None | Closed on: | |
| Version: | 8.6.18, 9.0.5, 9.1.0 | ||
| Description: | ||||
|
The following script,
results in the error, cannot yield: C stack busy | ||||
| User Comments: | ||||
sebres added on 2018-04-16 10:02:31:
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:
In above-mentioned example the flow is interrupted and endless wait is interrupted:
Just as notice to me: another still worse example (producing segfault ATM):
sebres added on 2018-04-16 12:25:51:
BTW. I assume that "TclNRCoroutineActivateCallback" (resp. inst_yield_to_invoke) are not NRE-safe (and should be fixed regardless of the vwait-repair). Currently any not compiled execution of yield (in body of something not compiled) raises a segfault resp. a panic "tailcall cannot find the right splicing spot: should not happen!" after resume from any "cannot yield: C stack busy"...
sebres added on 2018-04-16 18:16:47:
Another problem with yield across vwait/update etc is - event-cycle does not belong to the single interpreter. Theoretically one thread can have multiple interpreters (for example I myself have such systems e. g. with N workers * K interpreters), so despite I don't use coroutines resp. NRE-tailcalls across main-cycle, I would not like to use compiled vwait/update version, because it may cause unexpected (or rather unclear) flow-interruptions within single vwait's across multiple interpreters. Let alone it may not help in such case: I don't know how good such constructs will work within different TEBCResume segments.
I'll try to explain:
serhiy.storchaka added on 2026-10-17 08:47:42:
"Cannot yield: C stack busy" from a coroutine in an event handler under [vwait] is the same in all versions: vwait runs the event loop by nested C calls, and making it NRE-aware would be a larger design change. The panic "tailcall cannot find the right splicing spot" after a failed yieldto (sebres' scripts in the comments) was fixed for 9.0 in [eb50e83ee1] ([f9800d52bd]) and is now backported to core-8-6-branch in [d10cadf3ca], tests coroutine-7.13 and coroutine-7.14. | ||||
