mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix SIGSEGV caused by GC during fiber initialization
GC may occur in the `c->stbase = mrb_malloc()` part of the `fiber_init()` function. The `SIGSEGV` happens because it references the `c->ci->stack` field without checking `c->ci`. This is caused by #5272.
This commit is contained in:
@@ -1020,13 +1020,11 @@ gc_gray_counts(mrb_state *mrb, mrb_gc *gc, struct RBasic *obj)
|
||||
mrb_callinfo *ci;
|
||||
|
||||
if (!c || c->status == MRB_FIBER_TERMINATED) break;
|
||||
if (!c->ci) break;
|
||||
|
||||
/* mark stack */
|
||||
i = c->ci->stack - c->stbase;
|
||||
|
||||
if (c->ci) {
|
||||
i += mrb_ci_nregs(c->ci);
|
||||
}
|
||||
i += mrb_ci_nregs(c->ci);
|
||||
if (c->stbase + i > c->stend) i = c->stend - c->stbase;
|
||||
children += i;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user