From 645a464b2ddc085a7dd026aa8ae9f810a8ad4934 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Fri, 8 Dec 2023 09:33:05 +0900 Subject: [PATCH] mruby-fiber (fiber_to_s): retrieve position from terminated fibers; #6105 Since `cxt->ci` points to the last active callinfo, `cxt->ci == cxt->cibase` does not mean it does not have correct `proc` information, so we have removed the `f->cxt->ci > f->cxt->cibase` check. Instead, just in case `proc` does not have `irep` information, we try to confirm `proc` does not point to `CFUNC` nor is not an alias. --- mrbgems/mruby-fiber/src/fiber.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mrbgems/mruby-fiber/src/fiber.c b/mrbgems/mruby-fiber/src/fiber.c index 4b52097ab..e91415dfe 100644 --- a/mrbgems/mruby-fiber/src/fiber.c +++ b/mrbgems/mruby-fiber/src/fiber.c @@ -381,8 +381,9 @@ fiber_to_s(mrb_state *mrb, mrb_value self) const char *file; int32_t line; - if (f->cxt->ci > f->cxt->cibase && - mrb_debug_get_position(mrb, f->cxt->cibase->proc->body.irep, 0, &line, &file)) { + const struct RProc *p = f->cxt->cibase->proc; + if (!MRB_PROC_CFUNC_P(p) && !MRB_PROC_ALIAS_P(p) && + mrb_debug_get_position(mrb, p->body.irep, 0, &line, &file)) { mrb_str_cat_cstr(mrb, s, file); mrb_str_cat_lit(mrb, s, ":"); char buf[16];