-
Notifications
You must be signed in to change notification settings - Fork 795
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
calling Fiber#resume
directly from C causes error
#3056
Comments
Can you show us your code snippet? It doesn't have to be reproducible. |
@matz Thank you for looking into the issue. The diff is h2o/h2o@3152e4c. The commit removes the wrapper used to call With the change, the mruby handler of H2O stops working correctly; when called for the first time, it returns the argument passed to |
Have you tried |
|
@matz Thank you for the answer. Will use the proc workaround. @Asmod4n Thank you for the suggestion. Unfortunately as stated by @matz calling
FWIW, to be precise, the code does not protect A fiber switch should not be deterred unless when a C function is called from mruby; |
`mrb_fiber_resume()` can be called from C; ref #3056
When
Fiber#resume
is called directly from C, the method returns the argument passed, without running any code on the fiber context.Looking at the source code, it seems like that the fiber implementation is not handling such case.
In the current implementation,
fiber_switch
(called bymrb_fiber_resume
) replaces the content (i.e.mrb->c
) and returns, hoping that the VM will continue running the operations on the changed context. This works fine if mrb_context_run is the caller of mrb_fiber_resume.However in case
Fiber#resume
is called directly from C code,mrb_fiber_resume
returns directly tomrb_funcall_with_block
and then to the C code, without running the operations on the changed context.Originally discussed in this tweet. Sorry for the lack of code for reproducing the issue.
The text was updated successfully, but these errors were encountered: