dearblue · GitHub

added 6 commits

December 4, 2023 21:48
The main objective is to make sure that fiber can be handled from C.
Also, add a mechanism to detect that the mruby VM has stopped in the middle of the process.
If it stops halfway, the test will be terminated with `abort()`.
If `mrb_fiber_resume()` was called from a C function as a method definition, the mruby VM was not processed afterwards.
    Called Fiber.yield
    mrb_vm_exec()       <<-- returns from the function by CINFO_RESUMED
    fiber_switch()      <<-- this patch causes the value to return to its pre-call state
    mrb_fiber_resume()
    mrb_vm_exec()       <<-- previously, returns from the function immediately as it was CINFO_RESUMED
    ...
    main()
Need to return control from `mrb_vm_exec()` to the caller if `Fiber#resume` was done from C.
When a fiber switched by `Fiber.yield` is resumed by `Fiber#resume` by C, it is necessary to pop CI with `fiber_switch()`.
Previously, CI misalignment caused inconsistencies, including crashes, on the next `Fiber#resume`.
Previously, if the caller of `Fiber#resume` had a C function call, an inconsistency would occur.

@dearblue

Closed

@matz

@dearblue

dearblue added a commit to dearblue/mruby that referenced this pull request

Mar 8, 2024
Assertions were failing on exit if started with `mrb_fiber_resume()`.
The bug that caused it was introduced by commit  42308c4  (mruby#6106).
The bug was moved by commit  990e18a .

Merged

Read the original on github.com ↗