Skip to content

Fixed when combined mrb_fiber_resume() and Fiber#transfer#6136

Merged
matz merged 1 commit into
mruby:masterfrom
dearblue:fiber-fix
Jan 2, 2024
Merged

Fixed when combined mrb_fiber_resume() and Fiber#transfer#6136
matz merged 1 commit into
mruby:masterfrom
dearblue:fiber-fix

Conversation

@dearblue

Copy link
Copy Markdown
Contributor

For example, the following code was crashing.

#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>

int
main(int argc, char *argv[])
{
  mrb_state *mrb = mrb_open();

  mrb_value fiber = mrb_load_string(mrb, "Fiber.new { Fiber.new { 12345.6789 }.transfer }");
  mrb_value res = mrb_fiber_resume(mrb, fiber, 0, NULL);
  mrb_p(mrb, res);

  mrb_close(mrb);

  return 0;
}

This PR contains a commit to integrate the code for return from mrb_vm_exec().
If this is a problem, please let me know.

@dearblue dearblue requested a review from matz as a code owner December 31, 2023 05:32
@github-actions github-actions Bot added the core label Dec 31, 2023
For example, the following code was crashing.

```c
#include <mruby.h>
#include <mruby/compile.h>
#include <mruby/proc.h>

int
main(int argc, char *argv[])
{
  mrb_state *mrb = mrb_open();

  mrb_value fiber = mrb_load_string(mrb, "Fiber.new { Fiber.new { 12345.6789 }.transfer }");
  mrb_value res = mrb_fiber_resume(mrb, fiber, 0, NULL);
  mrb_p(mrb, res);

  mrb_close(mrb);

  return 0;
}
```
@dearblue

dearblue commented Jan 2, 2024

Copy link
Copy Markdown
Contributor Author

Changed conditional branching to be done after mrb->c->status = MRB_FIBER_RUNNING.
The "return code integration" that was first done in this PR may be done another time.

Is this patch too late for mruby 3.3?

@matz

matz commented Jan 2, 2024

Copy link
Copy Markdown
Member

I will merge this anyway. I think I can merge this PR before RC2.

@matz matz merged commit f0ab79b into mruby:master Jan 2, 2024
@dearblue

dearblue commented Jan 3, 2024

Copy link
Copy Markdown
Contributor Author

I will merge this anyway. I think I can merge this PR before RC2.

Thank you!

@dearblue dearblue deleted the fiber-fix branch January 3, 2024 02:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants