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 01d908d..ba9726c 100644
--- a/gc.c
+++ b/gc.c
@@ -2042,12 +2042,14 @@ 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 */
- if (objspace->heap.sweep_slots) {
- p->as.free.flags = 0;
- }
- else {
- GC_PROF_DEC_LIVE_NUM;
- add_freelist(objspace, p);
+ if ((VALUE)p != rb_thread_main()) {
+ if (objspace->heap.sweep_slots) {
+ p->as.free.flags = 0;
+ }
+ else {
+ GC_PROF_DEC_LIVE_NUM;
+ add_freelist(objspace, p);
+ }
}
}
else {
@@ -3048,7 +3050,8 @@ static int
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_MARK)) == FL_FINALIZE) {
+ if ((p->as.basic.flags & (FL_FINALIZE|FL_MARK)) == FL_FINALIZE &&
+ (VALUE)p != rb_thread_main()) {
if (BUILTIN_TYPE(p) != T_ZOMBIE) {
p->as.free.flags = FL_MARK | T_ZOMBIE; /* remain marked */
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.