Skip to content

Commit

Permalink
Do not free globals when threads are enabled
Browse files Browse the repository at this point in the history
When threads are enabled, it's possible that other threads are still
running while neko is shutting down. This means freeing builtins or the
thread local storage slot for the vm context may cause a crash on those
threads.
  • Loading branch information
tobil4sk committed Feb 15, 2025
1 parent ab37810 commit 256f845
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions vm/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,13 @@ int main( int argc, char *argv[] ) {
vm = NULL;
mload = NULL;
neko_vm_select(NULL);
#ifdef NEKO_THREADS
/* With threads enabled, other threads may crash if globals are freed,
so only do a garbage collection there. */
neko_gc_major();
#else
neko_global_free();
#endif
return r;
}

Expand Down

0 comments on commit 256f845

Please # to comment.