summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2023-12-12 10:45:59 -0500
committerPeter Zhu <[email protected]>2023-12-13 10:39:06 -0500
commitf8ddcecbdf34b8d33ed4311b34d498d4ff380a3e (patch)
treee89f99d7dcb034f4aea9388c617580ab95cf6374 /gc.c
parent0d53dba7ce900387397610c060cfa24758fc806a (diff)
[Bug #20061] Clear mark bits when rb_free_on_exit
When compiling with cppflags=-DRGENGC_CHECK_MODE, the following crashes: ``` $ RUBY_FREE_ON_EXIT=1 ./miniruby -e 0 -e: [BUG] obj_free: RVALUE_MARKED(0x0000000103570020 [3LM ] T_CLASS (anon)) != FALSE ``` This commit clears the mark bits when rb_free_on_exit is enabled.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/gc.c b/gc.c
index a8a55377d8..59c9162a89 100644
--- a/gc.c
+++ b/gc.c
@@ -4651,6 +4651,14 @@ rb_objspace_call_finalizer(rb_objspace_t *objspace)
/* Abort incremental marking and lazy sweeping to speed up shutdown. */
gc_abort(objspace);
+ if (rb_free_on_exit) {
+ for (int i = 0; i < SIZE_POOL_COUNT; i++) {
+ rb_size_pool_t *size_pool = &size_pools[i];
+ rb_heap_t *heap = SIZE_POOL_EDEN_HEAP(size_pool);
+ rgengc_mark_and_rememberset_clear(objspace, heap);
+ }
+ }
+
/* prohibit GC because force T_DATA finalizers can break an object graph consistency */
dont_gc_on();