summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNARUSE, Yui <naruse@airemix.jp>2023-01-18 20:15:28 +0900
committerNARUSE, Yui <naruse@airemix.jp>2023-01-18 20:15:28 +0900
commitd7fb4629b4058eb86be03760e6b9f1f272e44147 (patch)
treed98f0cc3aefc50b87f82341b646a864a01c3573c /test
parent44a3043d1182acf3147935d9c1564028b5538417 (diff)
merge revision(s) 837ef8911c638c3e2bdb6af710de7c1fac7b5f90: [Backport #19305]
Fix crash in TracePoint c_call for removed method trace_arg->id is the ID of the original method of an aliased method. If the original method is removed, then the lookup will fail. We should use trace_arg->called_id instead, which is the ID of the aliased method. Fixes [Bug #19305] --- test/ruby/test_settracefunc.rb | 23 +++++++++++++++++++++++ vm_trace.c | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-)
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_settracefunc.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb
index 6aa6d5911d..b68370d0a1 100644
--- a/test/ruby/test_settracefunc.rb
+++ b/test/ruby/test_settracefunc.rb
@@ -70,6 +70,29 @@ class TestSetTraceFunc < Test::Unit::TestCase
assert_nil(binding)
end
+ def test_c_call_removed_method
+ # [Bug #19305]
+ klass = Class.new do
+ attr_writer :bar
+ alias_method :set_bar, :bar=
+ remove_method :bar=
+ end
+
+ obj = klass.new
+ method_id = nil
+ parameters = nil
+
+ TracePoint.new(:c_call) { |tp|
+ method_id = tp.method_id
+ parameters = tp.parameters
+ }.enable {
+ obj.set_bar(1)
+ }
+
+ assert_equal(:bar=, method_id)
+ assert_equal([[:req]], parameters)
+ end
+
def test_call
events = []
name = "#{self.class}\##{__method__}"