Skip to content

Commit 68842b2

Browse files
committed
ObjectSpace.{dump,dump_all,dump_shapes} needs vm barrier.
1 parent 866e474 commit 68842b2

File tree

1 file changed

+40
-22
lines changed

1 file changed

+40
-22
lines changed

ext/objspace/objspace_dump.c

Lines changed: 40 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -776,15 +776,21 @@ static VALUE
776776
objspace_dump(VALUE os, VALUE obj, VALUE output)
777777
{
778778
struct dump_config dc = {0,};
779-
if (!RB_SPECIAL_CONST_P(obj)) {
780-
dc.cur_page_slot_size = rb_gc_obj_slot_size(obj);
781-
}
779+
VALUE result = Qnil;
780+
RB_VM_LOCKING() {
781+
rb_vm_barrier();
782+
783+
if (!RB_SPECIAL_CONST_P(obj)) {
784+
dc.cur_page_slot_size = rb_gc_obj_slot_size(obj);
785+
}
782786

783-
dump_output(&dc, output, Qnil, Qnil, Qnil);
787+
dump_output(&dc, output, Qnil, Qnil, Qnil);
784788

785-
dump_object(obj, &dc);
789+
dump_object(obj, &dc);
786790

787-
return dump_result(&dc);
791+
result = dump_result(&dc);
792+
}
793+
return result;
788794
}
789795

790796
static void
@@ -840,35 +846,47 @@ static VALUE
840846
objspace_dump_all(VALUE os, VALUE output, VALUE full, VALUE since, VALUE shapes)
841847
{
842848
struct dump_config dc = {0,};
843-
dump_output(&dc, output, full, since, shapes);
849+
VALUE result = Qnil;
850+
RB_VM_LOCKING() {
851+
rb_vm_barrier();
844852

845-
if (!dc.partial_dump || dc.since == 0) {
846-
/* dump roots */
847-
rb_objspace_reachable_objects_from_root(root_obj_i, &dc);
848-
if (dc.roots) dump_append(&dc, "]}\n");
849-
}
853+
dump_output(&dc, output, full, since, shapes);
850854

851-
if (RTEST(shapes)) {
852-
rb_shape_each_shape_id(shape_id_i, &dc);
853-
}
855+
if (!dc.partial_dump || dc.since == 0) {
856+
/* dump roots */
857+
rb_objspace_reachable_objects_from_root(root_obj_i, &dc);
858+
if (dc.roots) dump_append(&dc, "]}\n");
859+
}
860+
861+
if (RTEST(shapes)) {
862+
rb_shape_each_shape_id(shape_id_i, &dc);
863+
}
854864

855-
/* dump all objects */
856-
rb_objspace_each_objects(heap_i, &dc);
865+
/* dump all objects */
866+
rb_objspace_each_objects(heap_i, &dc);
857867

858-
return dump_result(&dc);
868+
result = dump_result(&dc);
869+
}
870+
return result;
859871
}
860872

861873
/* :nodoc: */
862874
static VALUE
863875
objspace_dump_shapes(VALUE os, VALUE output, VALUE shapes)
864876
{
865877
struct dump_config dc = {0,};
866-
dump_output(&dc, output, Qfalse, Qnil, shapes);
878+
VALUE result = Qnil;
879+
RB_VM_LOCKING() {
880+
rb_vm_barrier();
881+
882+
dump_output(&dc, output, Qfalse, Qnil, shapes);
867883

868-
if (RTEST(shapes)) {
869-
rb_shape_each_shape_id(shape_id_i, &dc);
884+
if (RTEST(shapes)) {
885+
rb_shape_each_shape_id(shape_id_i, &dc);
886+
}
887+
result = dump_result(&dc);
870888
}
871-
return dump_result(&dc);
889+
return result;
872890
}
873891

874892
void

0 commit comments

Comments
 (0)