@@ -1873,7 +1873,14 @@ build_id_to_obj_i(VALUE obj, void *data)
18731873{
18741874 st_table * id_to_obj_tbl = (st_table * )data ;
18751875 if (rb_shape_obj_has_id (obj )) {
1876- st_insert (id_to_obj_tbl , rb_obj_id (obj ), obj );
1876+ VALUE id = rb_obj_id (obj );
1877+ if (FIXNUM_P (id )) {
1878+ fprintf (stderr , "build_id_to_obj_i insert id=%llu, obj=%" PRIxVALUE "\n" , NUM2ULL (id ), obj );
1879+ }
1880+ else {
1881+ rb_bug ("Invalid object_id %s" , rb_obj_info (id ));
1882+ }
1883+ st_insert (id_to_obj_tbl , id , obj );
18771884 }
18781885}
18791886
@@ -1917,7 +1924,10 @@ obj_free_object_id(VALUE obj)
19171924 if (rb_shape_obj_has_id (obj )) {
19181925 VALUE obj_id = rb_obj_id (obj );
19191926 if (!FIXNUM_P (obj_id )) {
1920- rb_bug ("Corrupted object_id=%s obj=%s, shape_id=%d" , rb_obj_info (obj_id ), rb_obj_info (obj ), shape_id );
1927+ rb_bug ("Corrupted object_id=%s obj=%s / %" PRIxVALUE ", shape_id=%d" , rb_obj_info (obj_id ), rb_obj_info (obj ), obj , shape_id );
1928+ }
1929+ else {
1930+ fprintf (stderr , "obj_free_object_id delete id=%llu, obj=%" PRIxVALUE "\n" , NUM2ULL (id ), obj );
19211931 }
19221932 st_data_t id = (st_data_t )obj_id ;
19231933 GC_ASSERT (id );
@@ -3701,6 +3711,7 @@ vm_weak_table_id_to_obj_foreach(st_data_t key, st_data_t value, st_data_t data)
37013711 if (value != new_value ) {
37023712 DURING_GC_COULD_MALLOC_REGION_START ();
37033713 {
3714+ fprintf (stderr , "vm_weak_table_id_to_obj_foreach insert id=%llu, obj=%" PRIxVALUE "\n" , NUM2ULL ((VALUE )key ), new_value );
37043715 st_insert (id_to_obj_tbl , key , (st_data_t )new_value );
37053716 }
37063717 DURING_GC_COULD_MALLOC_REGION_END ();
@@ -5298,7 +5309,7 @@ rb_gc_after_fork(rb_pid_t pid)
52985309void
52995310Init_GC (void )
53005311{
5301- id_to_obj_tbl = st_init_table (& object_id_hash_type );
5312+ id_to_obj_tbl = st_init_table (& object_id_hash_type ); // DEBUG: make bug more likely to trigger.
53025313#undef rb_intern
53035314 rb_gc_register_address (& id_to_obj_value );
53045315
0 commit comments