Skip to content

Commit

Permalink
Merge pull request #2334 from natalie-lang/thread-system-exit
Browse files Browse the repository at this point in the history
Fix SystemExit segfault for non-main threads
  • Loading branch information
seven1m authored Nov 14, 2024
2 parents 9bb0ca9 + e615da3 commit 1dacb3d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/natalie.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -837,10 +837,12 @@ Value super(Env *env, Value self, Args args, Block *block) {
}

void clean_up_and_exit(int status) {
ThreadObject::detach_all();
if (Heap::the().collect_all_at_exit()) {
delete &Heap::the();
delete NativeProfiler::the();
if (ThreadObject::i_am_main()) {
ThreadObject::detach_all();
if (Heap::the().collect_all_at_exit()) {
delete &Heap::the();
delete NativeProfiler::the();
}
}
exit(status);
}
Expand Down

0 comments on commit 1dacb3d

Please sign in to comment.