verify_internal_consistency()
  public
  
    
    
Verify internal consistency.
This method is implementation specific. Now this method checks generational
consistency if RGenGC is supported.
   
  
    Show source    
    
      static VALUE
gc_verify_internal_consistency(VALUE dummy)
{
    rb_objspace_t *objspace = &rb_objspace;
    struct verify_internal_consistency_struct data = {0};
    struct each_obj_args eo_args;
    data.objspace = objspace;
    gc_report(5, objspace, "gc_verify_internal_consistency: start\n");
    /* check relations */
    eo_args.callback = verify_internal_consistency_i;
    eo_args.data = (void *)&data;
    objspace_each_objects((VALUE)&eo_args);
    if (data.err_count != 0) {
        objspace->rgengc.error_count = data.err_count;
        gc_marks_check(objspace, NULL, NULL);
        allrefs_dump(objspace);
        rb_bug("gc_verify_internal_consistency: found internal inconsistency.");
    }
    /* check heap_page status */
    gc_verify_heap_pages(objspace);
    /* check counters */
    if (!is_lazy_sweeping(heap_eden) && !finalizing) {
        if (objspace_live_slots(objspace) != data.live_object_count) {
            fprintf(stderr, "heap_pages_final_slots: %d, objspace->profile.total_freed_objects: %d\n",
                    (int)heap_pages_final_slots, (int)objspace->profile.total_freed_objects);
            rb_bug("inconsistent live slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace_live_slots(objspace), data.live_object_count);
        }
    }
    if (!is_marking(objspace)) {
        if (objspace->rgengc.old_objects != data.old_object_count) {
            rb_bug("inconsistent old slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.old_objects, data.old_object_count);
        }
        if (objspace->rgengc.uncollectible_wb_unprotected_objects != data.remembered_shady_count) {
            rb_bug("inconsistent old slot nubmer: expect %"PRIuSIZE", but %"PRIuSIZE".", objspace->rgengc.uncollectible_wb_unprotected_objects, data.remembered_shady_count);
        }
    }
    if (!finalizing) {
        size_t list_count = 0;
        {
            VALUE z = heap_pages_deferred_final;
            while (z) {
                list_count++;
                z = RZOMBIE(z)->next;
            }
        }
        if (heap_pages_final_slots != data.zombie_object_count ||
            heap_pages_final_slots != list_count) {
            rb_bug("inconsistent finalizing object count:\n"
                   "  expect %"PRIuSIZE"\n"
                   "  but    %"PRIuSIZE" zombies\n"
                   "  heap_pages_deferred_final list has %"PRIuSIZE" items.",
                   heap_pages_final_slots,
                   data.zombie_object_count,
                   list_count);
        }
    }
    gc_report(5, objspace, "gc_verify_internal_consistency: OK\n");
    return Qnil;
}