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:
dearblue
2022-07-30 22:32:02 +09:00
parent 9e38aa8948
commit a82a3533e6
+2 -4
View File
@@ -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;