Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/libAtomVM/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ void context_destroy(Context *ctx)
struct ListHead *processes_table_list = synclist_wrlock(&ctx->global->processes_table);
UNUSED(processes_table_list);

// Remove from scheduling lists (waiting/ready/running).
// list_remove on a self-referential (already removed + re-initialized) node is a safe no-op.
SMP_SPINLOCK_LOCK(&ctx->global->processes_spinlock);
list_remove(&ctx->processes_list_head);
list_init(&ctx->processes_list_head);
SMP_SPINLOCK_UNLOCK(&ctx->global->processes_spinlock);

list_remove(&ctx->processes_table_head);

// Ensure process is not registered
Expand Down
4 changes: 1 addition & 3 deletions src/libAtomVM/scheduler.c
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,6 @@ Context *scheduler_run(GlobalContext *global)
// process signal messages and also empty outer list to inner list.
scheduler_process_native_signal_messages(result);
if (UNLIKELY(result->flags & Killed)) {
SMP_SPINLOCK_LOCK(&global->processes_spinlock);
list_remove(&result->processes_list_head);
SMP_SPINLOCK_UNLOCK(&global->processes_spinlock);
context_destroy(result);
} else {
if (mailbox_has_next(&result->mailbox)) {
Expand Down Expand Up @@ -429,6 +426,7 @@ void scheduler_terminate(Context *ctx)
SMP_SPINLOCK_LOCK(&ctx->global->processes_spinlock);
context_update_flags(ctx, ~NoFlags, Killed);
list_remove(&ctx->processes_list_head);
list_init(&ctx->processes_list_head);
SMP_SPINLOCK_UNLOCK(&ctx->global->processes_spinlock);
if (!ctx->leader) {
context_destroy(ctx);
Expand Down
Loading