From 618d4e06f1550cb6583e9f99df29060343901af5 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Mon, 23 Nov 2026 18:52:26 -0600 Subject: [PATCH] Minimal fix for #1948 - ev cancel in janet_dobytes run.c should initialize fibers nicely, but a more general fix is ideal for top level functions that call into the event loop. --- src/core/run.c | 2 +- src/core/vm.c | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/core/run.c b/src/core/run.c index 2846f818..cc09b094 100644 --- a/src/core/run.c +++ b/src/core/run.c @@ -26,7 +26,7 @@ #include "state.h" #endif -/* Run a string of code. The return value is a set of error flags, JANET_DO_ERROR_RUNTIME, JANET_DO_ERROR_COMPILE, and JANET_DOR_ERROR_PARSE if +/* Run a string of code. The return value is a set of error flags, JANET_DO_ERROR_RUNTIME, JANET_DO_ERROR_COMPILE, and JANET_DO_ERROR_PARSE if * any errors were encountered in those phases. More information is printed to stderr. */ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char *sourcePath, Janet *out) { JanetParser *parser; diff --git a/src/core/vm.c b/src/core/vm.c index 7e29909f..ec7cf34e 100644 --- a/src/core/vm.c +++ b/src/core/vm.c @@ -1562,6 +1562,12 @@ static JanetSignal janet_check_can_resume(JanetFiber *fiber, Janet *out, int is_ *out = janet_wrap_string(str); return JANET_SIGNAL_ERROR; } +#ifdef JANET_EV + if (janet_vm.fiber == NULL) { + /* Make sure we don't run root fibers without this flag */ + fiber->gc.flags |= JANET_FIBER_EV_GCFLAG_ROOT; + } +#endif return JANET_SIGNAL_OK; }