From 66a7c92938638e3afceb1d92ae877376902a71a0 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 13 May 2019 12:59:30 -0700 Subject: [PATCH] Don't run the compactor if GC is disabled GC is required for pinning / marking objects. If the compactor runs without pinning everything, then it will blow up, so just return early if the GC is disabled. --- gc.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gc.c b/gc.c index 7a957006b8..55af43720e 100644 --- a/gc.c +++ b/gc.c @@ -7322,7 +7322,7 @@ gc_move(rb_objspace_t *objspace, VALUE scan, VALUE free) RVALUE *dest = (RVALUE *)free; RVALUE *src = (RVALUE *)scan; - gc_report(4, objspace, "Moving object: %s -> %p\n", obj_info(scan), (void *)free); + gc_report(4, objspace, "Moving object: %p -> %p\n", (void*)scan, (void *)free); GC_ASSERT(BUILTIN_TYPE(scan) != T_NONE); GC_ASSERT(BUILTIN_TYPE(free) == T_NONE); @@ -7867,7 +7867,7 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj) { RVALUE *any = RANY(obj); - gc_report(4, objspace, "update-refs: %s ->", obj_info(obj)); + gc_report(4, objspace, "update-refs: %p ->", (void *)obj); switch(BUILTIN_TYPE(obj)) { case T_CLASS: @@ -8013,8 +8013,9 @@ gc_update_object_references(rb_objspace_t *objspace, VALUE obj) UPDATE_IF_MOVED(objspace, RBASIC(obj)->klass); - gc_report(4, objspace, "update-refs: %s <-", obj_info(obj)); + gc_report(4, objspace, "update-refs: %p <-", (void *)obj); } + static int gc_ref_update(void *vstart, void *vend, size_t stride, void * data) { @@ -8067,6 +8068,8 @@ gc_update_references(rb_objspace_t * objspace) rb_objspace_each_objects_without_setup(gc_ref_update, objspace); rb_vm_update_references(vm); rb_transient_heap_update_references(); + global_symbols.ids = rb_gc_new_location(global_symbols.ids); + global_symbols.dsymbol_fstr_hash = rb_gc_new_location(global_symbols.dsymbol_fstr_hash); gc_update_table_refs(objspace, global_symbols.str_sym); } @@ -8101,6 +8104,7 @@ rb_gc_compact(VALUE mod) { rb_objspace_t *objspace = &rb_objspace; + if (dont_gc) return Qnil; /* Ensure objects are pinned */ rb_gc(); @@ -8192,6 +8196,8 @@ gc_verify_compaction_references(VALUE mod) { rb_objspace_t *objspace = &rb_objspace; + if (dont_gc) return Qnil; + /* Ensure objects are pinned */ rb_gc();