diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-14 04:46:22 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2015-02-14 04:46:22 +0000 |
commit | 43defa70006d957574578503365fef8d4d18c646 (patch) | |
tree | a72409ef2141abc2b0ed16b5da6533608e067499 /test | |
parent | 68c6739e965cc5e7b0dd57d787a69126be45b865 (diff) |
merge revision(s) 49499,49500,49501,49502,49504,49505,49506,49507: [Backport #10828]
* vm_insnhelper.c: Fix one type of symbol leak with +send+
* vm_insnhelper.c: Fix symbol leak with +send+ [Bug #10828]
* vm_insnhelper.c (ci_missing_reason): return the reason of method
missing in call info.
* vm_insnhelper.c (vm_call_opt_send): re-apply r49500 with the
proper missing reason. [Bug #10828]
* vm_eval.c (send_internal), vm_insnhelper.c (vm_call_opt_send):
convert String method name into a Symbol, as method_missing
method expects its first argument to be a Symbol. [Bug #10828]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@49598 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/-ext-/symbol/test_inadvertent_creation.rb | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/test/-ext-/symbol/test_inadvertent_creation.rb b/test/-ext-/symbol/test_inadvertent_creation.rb index b180d08b04..9262fc3396 100644 --- a/test/-ext-/symbol/test_inadvertent_creation.rb +++ b/test/-ext-/symbol/test_inadvertent_creation.rb @@ -358,5 +358,73 @@ module Test_Symbol } assert_not_pinneddown(name) end + + def assert_no_immortal_symbol_created(name) + name = noninterned_name(name) + yield(name) + assert_not_pinneddown(name) + end + + def assert_no_immortal_symbol_in_method_missing(name) + assert_no_immortal_symbol_created("send should not leak - #{name}") do |name| + assert_raise(NoMethodError) {yield(name)} + end + end + + def test_send_leak_string + assert_no_immortal_symbol_in_method_missing("str") do |name| + 42.send(name) + end + end + + def test_send_leak_symbol + assert_no_immortal_symbol_in_method_missing("sym") do |name| + 42.send(name.to_sym) + end + end + + def test_send_leak_string_custom_method_missing + x = Object.new + def x.method_missing(*); super; end + assert_no_immortal_symbol_in_method_missing("str mm") do |name| + x.send(name) + end + end + + def test_send_leak_symbol_custom_method_missing + x = Object.new + def x.method_missing(*); super; end + assert_no_immortal_symbol_in_method_missing("sym mm") do |name| + x.send(name.to_sym) + end + end + + def test_send_leak_string_no_optimization + assert_no_immortal_symbol_in_method_missing("str slow") do |name| + 42.method(:send).call(name) + end + end + + def test_send_leak_symbol_no_optimization + assert_no_immortal_symbol_in_method_missing("sym slow") do |name| + 42.method(:send).call(name.to_sym) + end + end + + def test_send_leak_string_custom_method_missing_no_optimization + x = Object.new + def x.method_missing(*); super; end + assert_no_immortal_symbol_in_method_missing("str mm slow") do |name| + x.method(:send).call(name) + end + end + + def test_send_leak_symbol_custom_method_missing_no_optimization + x = Object.new + def x.method_missing(*); super; end + assert_no_immortal_symbol_in_method_missing("sym mm slow") do |name| + x.method(:send).call(name.to_sym) + end + end end end |