Skip to content

Commit 6be4221

Browse files
committed
Prevent GC from running during process teardown
1 parent bbb0596 commit 6be4221

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/signals-unix.c

+6
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,12 @@ static void *signal_listener(void *arg)
10331033
}
10341034
#endif
10351035
if (doexit) {
1036+
// Let's forbid threads from running GC while we're trying to exit,
1037+
// also let's make sure we're not in the middle of GC.
1038+
jl_atomic_fetch_add(&jl_gc_disable_counter, 1);
1039+
while (jl_atomic_load_acquire(&jl_gc_running)) {
1040+
jl_cpu_pause();
1041+
}
10361042
// The exit can get stuck if it happens at an unfortunate spot in thread 0
10371043
// (unavoidable due to its async nature).
10381044
// Try much harder to exit next time, if we get multiple exit requests.

0 commit comments

Comments
 (0)