Disable GC even during finalizing
We're seeing a crash during shutdown in rb_gc_impl_objspace_free because it's running lazy sweeping during shutdown. It appears that it's due to `finalizing` being set, which causes GC to not be aborted and not disabled which causes it to be in lazy sweeping at shutdown. The full stack trace is: #6 rb_bug (fmt=fmt@entry=0x5643b8ebde78 "lazy sweeping underway when freeing object space") at error.c:1095 #7 0x00005643b8a3c697 in rb_gc_impl_objspace_free (objspace_ptr=<optimized out>) at gc/default.c:9507 #8 0x00005643b8c269eb in ruby_vm_destruct (vm=0x7e2fdc84d000) at vm.c:3141 #9 0x00005643b8a5147b in rb_ec_cleanup (ec=<optimized out>, ex=<optimized out>) at eval.c:263 #10 0x00005643b8a51c93 in ruby_run_node (n=<optimized out>) at eval.c:319 #11 0x00005643b8a4c7c7 in rb_main (argv=0x7fffef15e7f8, argc=18) at ./main.c:43 #12 main (argc=<optimized out>, argv=<optimized out>) at ./main.c:62
This commit is contained in:
parent
da8cf99cb5
commit
868d63f0a3
Notes:
git
2024-08-08 14:12:07 +00:00
@ -3233,11 +3233,17 @@ rb_gc_impl_shutdown_call_finalizer(void *objspace_ptr)
|
||||
#if RGENGC_CHECK_MODE >= 2
|
||||
gc_verify_internal_consistency(objspace);
|
||||
#endif
|
||||
if (RUBY_ATOMIC_EXCHANGE(finalizing, 1)) return;
|
||||
|
||||
/* prohibit incremental GC */
|
||||
objspace->flags.dont_incremental = 1;
|
||||
|
||||
if (RUBY_ATOMIC_EXCHANGE(finalizing, 1)) {
|
||||
/* Abort incremental marking and lazy sweeping to speed up shutdown. */
|
||||
gc_abort(objspace);
|
||||
dont_gc_on();
|
||||
return;
|
||||
}
|
||||
|
||||
/* force to run finalizer */
|
||||
while (finalizer_table->num_entries) {
|
||||
struct force_finalize_list *list = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user