Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/gc.c b/gc.c
index 63869a0..e15f141 100644
--- a/gc.c
+++ b/gc.c
@@ -1420,9 +1420,11 @@ finalize_list(rb_objspace_t *objspace, RVALUE *p)
RVALUE *tmp = p->as.free.next;
run_final(objspace, (VALUE)p);
if (!FL_TEST(p, FL_SINGLETON)) { /* not freeing page */
- add_slot_local_freelist(objspace, p);
- if (!is_lazy_sweeping(objspace)) {
- gc_prof_dec_live_num(objspace);
+ if ((VALUE)p != rb_thread_main()) {
+ add_slot_local_freelist(objspace, p);
+ if (!is_lazy_sweeping(objspace)) {
+ gc_prof_dec_live_num(objspace);
+ }
}
}
else {
@@ -1458,7 +1460,8 @@ chain_finalized_object(st_data_t key, st_data_t val, st_data_t arg)
{
RVALUE *p = (RVALUE *)key, **final_list = (RVALUE **)arg;
if ((p->as.basic.flags & FL_FINALIZE) == FL_FINALIZE &&
- !MARKED_IN_BITMAP(GET_HEAP_BITMAP(p), p)) {
+ !MARKED_IN_BITMAP(GET_HEAP_BITMAP(p), p) &&
+ (VALUE)p != rb_thread_main()) {
if (BUILTIN_TYPE(p) != T_ZOMBIE) {
p->as.free.flags = T_ZOMBIE;
RDATA(p)->dfree = 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.