diff options
author | nagachika <nagachika@ruby-lang.org> | 2021-11-23 14:19:44 +0900 |
---|---|---|
committer | nagachika <nagachika@ruby-lang.org> | 2021-11-23 14:52:29 +0900 |
commit | b6f87d527f59257f07ba6774addaefdedee4fcde (patch) | |
tree | 4190f6599a6f560f4a8c9ff0a4e49fd2a7a5ba95 /test/ruby | |
parent | 32342c9fcaaf64f5d6b86ea4e041c9331fb381d3 (diff) |
merge revision(s) 84202963c52e02cecad3e6b2fad478bfbeee1bc7: [Backport #18329]
[Bug #18329] Fix crash when calling non-existent super method
The cme is NULL when a method does not exist, so check it before
accessing the callcache.
---
test/ruby/test_super.rb | 31 +++++++++++++++++++++++++++++++
vm_insnhelper.c | 3 ++-
2 files changed, 33 insertions(+), 1 deletion(-)
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_super.rb | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/test/ruby/test_super.rb b/test/ruby/test_super.rb index d94f4679d3..3afde9b0e3 100644 --- a/test/ruby/test_super.rb +++ b/test/ruby/test_super.rb @@ -521,6 +521,37 @@ class TestSuper < Test::Unit::TestCase assert_equal(%w[B A], result, bug9721) end + # [Bug #18329] + def test_super_missing_prepended_module + a = Module.new do + def probe(*methods) + prepend(probing_module(methods)) + end + + def probing_module(methods) + Module.new do + methods.each do |method| + define_method(method) do |*args, **kwargs, &block| + super(*args, **kwargs, &block) + end + end + end + end + end + + b = Class.new do + extend a + + probe :danger!, :missing + + def danger!; end + end + + o = b.new + o.danger! + 2.times { o.missing rescue NoMethodError } + end + def test_from_eval bug10263 = '[ruby-core:65122] [Bug #10263a]' a = Class.new do |