ruby-changes:38901
From: sorah <ko1@a...>
Date: Sun, 21 Jun 2015 05:50:47 +0900 (JST)
Subject: [ruby-changes:38901] sorah:r50982 (trunk): * ext/objspace/objspace_dump.c(dump_object): Return empty JSON object when
sorah 2015-06-21 05:50:20 +0900 (Sun, 21 Jun 2015) New Revision: 50982 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50982 Log: * ext/objspace/objspace_dump.c(dump_object): Return empty JSON object when passed object is a special const, instead of SEGV. Based patch by Kohei Suzuki (eagletmt). [ruby-core:69692] [Bug #11291] * test/objspace/test_objspace.rb(test_dump_special_consts): Test for above fix. Modified files: trunk/ChangeLog trunk/ext/objspace/objspace_dump.c trunk/test/objspace/test_objspace.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 50981) +++ ChangeLog (revision 50982) @@ -1,3 +1,12 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sun Jun 21 05:31:41 2015 Shota Fukumori <her@s...> + + * ext/objspace/objspace_dump.c(dump_object): Return empty JSON object when + passed object is a special const, instead of SEGV. + Based patch by Kohei Suzuki (eagletmt). [ruby-core:69692] [Bug #11291] + + * test/objspace/test_objspace.rb(test_dump_special_consts): Test for above fix. + + Sat Jun 20 03:56:58 2015 Yusuke Endoh <mame@r...> * enc/make_encmake.rb: the list of encoding extension libraries must Index: ext/objspace/objspace_dump.c =================================================================== --- ext/objspace/objspace_dump.c (revision 50981) +++ ext/objspace/objspace_dump.c (revision 50982) @@ -149,6 +149,11 @@ dump_object(VALUE obj, struct dump_confi https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L149 ID flags[RB_OBJ_GC_FLAGS_MAX]; size_t n, i; + if (SPECIAL_CONST_P(obj)) { + dump_append(dc, "{}"); + return; + } + dc->cur_obj = obj; dc->cur_obj_references = 0; dc->cur_obj_klass = BUILTIN_TYPE(obj) == T_NODE ? 0 : RBASIC_CLASS(obj); Index: test/objspace/test_objspace.rb =================================================================== --- test/objspace/test_objspace.rb (revision 50981) +++ test/objspace/test_objspace.rb (revision 50982) @@ -243,6 +243,15 @@ class TestObjSpace < Test::Unit::TestCas https://github.com/ruby/ruby/blob/trunk/test/objspace/test_objspace.rb#L243 assert_match /"method":"#{loc.base_label}"/, info end + def test_dump_special_consts + # [ruby-core:69692] [Bug #11291] + assert_equal('{}', ObjectSpace.dump(nil)) + assert_equal('{}', ObjectSpace.dump(true)) + assert_equal('{}', ObjectSpace.dump(false)) + assert_equal('{}', ObjectSpace.dump(0)) + assert_equal('{}', ObjectSpace.dump(:foo)) + end + def test_dump_all entry = /"bytesize":11, "value":"TEST STRING", "encoding":"UTF-8", "file":"-", "line":4, "method":"dump_my_heap_please", "generation":/ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/