From 3410539bf358d3b4a44f5c6e0be7e2fd66aa24fe Mon Sep 17 00:00:00 2001 From: Peter M Date: Mon, 20 Apr 2026 22:33:06 +0200 Subject: [PATCH] scheduler: block task wakeups during spawn Match scheduler_make_ready_from_task with scheduler_make_ready by checking the Spawning flag as well as Killed before moving a process onto the ready queue. Without this guard, a task-driven message can wake a newly spawned process after its pid is visible but before scheduler_init_ready clears Spawning, which can schedule a not-yet-initialized context. Keep the locking model unchanged: the task-side path still relies on the caller already holding processes_spinlock. Signed-off-by: Peter M --- src/libAtomVM/scheduler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libAtomVM/scheduler.c b/src/libAtomVM/scheduler.c index a856d60012..ba48d0c967 100644 --- a/src/libAtomVM/scheduler.c +++ b/src/libAtomVM/scheduler.c @@ -393,7 +393,7 @@ static void scheduler_make_ready(Context *ctx) static void scheduler_make_ready_from_task(Context *ctx) { GlobalContext *global = ctx->global; - if (context_get_flags(ctx, Killed)) { + if (context_get_flags(ctx, Killed | Spawning)) { return; } list_remove(&ctx->processes_list_head);