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:
Bob Nystrom
2018-07-21 17:02:29 +00:00
parent daeff98b83
commit 4b160f017b
11 changed files with 240 additions and 12 deletions
+8
View File
@@ -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()