diff options
author | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-29 04:28:15 +0000 |
---|---|---|
committer | usa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-06-29 04:28:15 +0000 |
commit | 61f3baeef9003de4651419fa27ee97c18c8ce170 (patch) | |
tree | 920bc8ec2cc0904675c8d4053ff8a449355dd6e5 | |
parent | 9af0f53f6d2ba6f9a40b23b6f9816a69814d1f96 (diff) |
merge revision(s) 50982,50983: [Backport #11291]
* 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.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51059 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ext/objspace/objspace_dump.c | 5 | ||||
-rw-r--r-- | test/objspace/test_objspace.rb | 9 | ||||
-rw-r--r-- | version.h | 6 |
4 files changed, 26 insertions, 3 deletions
@@ -1,3 +1,12 @@ +Mon Jun 29 13:22:14 2015 Shota Fukumori <her@sorah.jp> + + * 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. + + Wed Jun 17 11:39:15 2015 Koichi Sasada <ko1@atdot.net> * vm_insnhelper.c (lep_svar_set): add WBs. diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index e3ce7e727d..f61c3de249 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -152,6 +152,11 @@ dump_object(VALUE obj, struct dump_config *dc) 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); diff --git a/test/objspace/test_objspace.rb b/test/objspace/test_objspace.rb index 7c4dc0bff9..8a15e1c765 100644 --- a/test/objspace/test_objspace.rb +++ b/test/objspace/test_objspace.rb @@ -234,6 +234,15 @@ class TestObjSpace < Test::Unit::TestCase 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":/ @@ -1,10 +1,10 @@ #define RUBY_VERSION "2.1.7" -#define RUBY_RELEASE_DATE "2015-06-17" -#define RUBY_PATCHLEVEL 367 +#define RUBY_RELEASE_DATE "2015-06-29" +#define RUBY_PATCHLEVEL 368 #define RUBY_RELEASE_YEAR 2015 #define RUBY_RELEASE_MONTH 6 -#define RUBY_RELEASE_DAY 17 +#define RUBY_RELEASE_DAY 29 #include "ruby/version.h" |