summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authorAaron Patterson <tenderlove@ruby-lang.org>2019-10-29 08:13:38 -0700
committerAaron Patterson <tenderlove@ruby-lang.org>2019-10-29 08:13:38 -0700
commit22dbbbeb32b88708b9ea371e856c48c5d9ad3e63 (patch)
treec9090fa0971f7f87c530b09e230f72148c5385f7 /gc.c
parentfee5cde00be7342dc6c00d0b0a0276d09e5252e3 (diff)
Compacting the heap can cause GC, so disable it
When we compact the heap, various st tables are updated, particularly the table that contains the object id map. Updating an st table can cause a GC to occur, and we need to prevent any GC from happening while moving or updating references.
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index 6fcdf2a53c..97133e6a23 100644
--- a/gc.c
+++ b/gc.c
@@ -8554,6 +8554,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl
}
VALUE moved_list;
+ VALUE disabled = rb_gc_disable();
if (use_toward_empty) {
moved_list = gc_compact_heap(objspace, compare_free_slots);
@@ -8563,7 +8564,6 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl
}
heap_eden->freelist = NULL;
- VALUE disabled = rb_gc_disable();
gc_update_references(objspace);
if (!RTEST(disabled)) rb_gc_enable();