Ease fiber limitations - #6106
Merged
Merged
Conversation
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()`.
This patch is effectively reverts to the following: - commit dc65b1f (mruby#5782) - commit f4c4809 (mruby#5947) Ref. mruby#6063
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
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Neutralizes restriction #5782 introduced by
Fiber#resumeissue #5781.ref. #6063