Skip to content

Commit e7695ba

Browse files
peterzhu2118matzbot
authored andcommitted
[ruby/mmtk] Check for T_NONE during marking
ruby/mmtk@c3e338bb25
1 parent 31fb970 commit e7695ba

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

gc/mmtk/mmtk.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ struct MMTk_final_job {
7272

7373
#ifdef RB_THREAD_LOCAL_SPECIFIER
7474
RB_THREAD_LOCAL_SPECIFIER struct MMTk_GCThreadTLS *rb_mmtk_gc_thread_tls;
75+
76+
RB_THREAD_LOCAL_SPECIFIER VALUE marking_parent_object;
7577
#else
7678
# error We currently need language-supported TLS
7779
#endif
@@ -270,26 +272,34 @@ rb_mmtk_update_object_references(MMTk_ObjectReference mmtk_object)
270272
VALUE object = (VALUE)mmtk_object;
271273

272274
if (!RB_FL_TEST(object, RUBY_FL_WEAK_REFERENCE)) {
275+
marking_parent_object = object;
273276
rb_gc_update_object_references(rb_gc_get_objspace(), object);
277+
marking_parent_object = 0;
274278
}
275279
}
276280

277281
static void
278282
rb_mmtk_call_gc_mark_children(MMTk_ObjectReference object)
279283
{
284+
marking_parent_object = (VALUE)object;
280285
rb_gc_mark_children(rb_gc_get_objspace(), (VALUE)object);
286+
marking_parent_object = 0;
281287
}
282288

283289
static void
284290
rb_mmtk_handle_weak_references(MMTk_ObjectReference mmtk_object, bool moving)
285291
{
286292
VALUE object = (VALUE)mmtk_object;
287293

294+
marking_parent_object = object;
295+
288296
rb_gc_handle_weak_references(object);
289297

290298
if (moving) {
291299
rb_gc_update_object_references(rb_gc_get_objspace(), object);
292300
}
301+
302+
marking_parent_object = 0;
293303
}
294304

295305
static void
@@ -797,6 +807,17 @@ void rb_gc_impl_adjust_memory_usage(void *objspace_ptr, ssize_t diff) { }
797807
static inline VALUE
798808
rb_mmtk_call_object_closure(VALUE obj, bool pin)
799809
{
810+
if (RB_UNLIKELY(RB_BUILTIN_TYPE(obj) == T_NONE)) {
811+
const size_t info_size = 256;
812+
char obj_info_buf[info_size];
813+
rb_raw_obj_info(obj_info_buf, info_size, obj);
814+
815+
char parent_obj_info_buf[info_size];
816+
rb_raw_obj_info(parent_obj_info_buf, info_size, marking_parent_object);
817+
818+
rb_bug("try to mark T_NONE object (obj: %s, parent: %s)", obj_info_buf, parent_obj_info_buf);
819+
}
820+
800821
return (VALUE)rb_mmtk_gc_thread_tls->object_closure.c_function(
801822
rb_mmtk_gc_thread_tls->object_closure.rust_closure,
802823
rb_mmtk_gc_thread_tls->gc_context,

0 commit comments

Comments
 (0)