Skip to content

Commit e1e3d4f

Browse files
committed
Prevent GC from running during process teardown
1 parent fb01f91 commit e1e3d4f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/signals-unix.c

+4
Original file line numberDiff line numberDiff line change
@@ -1033,6 +1033,10 @@ 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+
jl_safepoint_wait_gc(NULL);
10361040
// The exit can get stuck if it happens at an unfortunate spot in thread 0
10371041
// (unavoidable due to its async nature).
10381042
// Try much harder to exit next time, if we get multiple exit requests.

0 commit comments

Comments
 (0)