feat: prevent calling root fiber and refactor fiber state tracking
Add explicit check in `runFiber()` to reject calls to the root fiber, preventing VM crashes when a completed fiber's caller tries to resume it. Replace the boolean `callerIsTrying` field with a `FiberState` enum (`FIBER_TRY`, `FIBER_ROOT`, `FIBER_OTHER`) to track fiber invocation mode, updating all relevant primitives and initialization. Include new test cases (`call_root.wren`, `call_wren_call_root.*`) and re-entrancy documentation notes.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
var root = Fiber.current
|
||||
System.print("begin root") // expect: begin root
|
||||
|
||||
Fiber.new {
|
||||
System.print("in new fiber") // expect: in new fiber
|
||||
root.call() // expect runtime error: Cannot call root fiber.
|
||||
System.print("called root")
|
||||
}.transfer()
|
||||
Reference in New Issue
Block a user