Skip to content

Commit

Permalink
[Bug #20061] Clear mark bits when rb_free_on_exit
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
peterzhu2118 committed Dec 13, 2023
1 parent 0d53dba commit f8ddcec
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gc.c
Expand Up @@ -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();

Expand Down

0 comments on commit f8ddcec

Please sign in to comment.