From eba3f787cbd38acf60fff6bdb450aacfc2e9c3a1 Mon Sep 17 00:00:00 2001 From: nagachika Date: Tue, 21 Mar 2023 12:00:17 +0900 Subject: 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(-) --- test/ruby/test_settracefunc.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_settracefunc.rb b/test/ruby/test_settracefunc.rb index c25debb38e..73d8aee6a2 100644 --- a/test/ruby/test_settracefunc.rb +++ b/test/ruby/test_settracefunc.rb @@ -50,6 +50,29 @@ class TestSetTraceFunc < Test::Unit::TestCase assert_equal([], events) 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__}" -- cgit v1.2.3