forked from Mirror/wren
Don't allow calling the root fiber.
The VM used to not detect this case. It meant you could get into a situation where another fiber's caller had completed. Then, when it tried to resume that fiber, the VM would crash because there was nothing to resume to. This is part of thinking through all the cases around re-entrancy. Added some notes for that too.
This commit is contained in:
8
test/core/fiber/call_root.wren
Normal file
8
test/core/fiber/call_root.wren
Normal 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()
|
||||
Reference in New Issue
Block a user