<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/vm_trace.c, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>merge revision(s) 660b995365f719fa59ed6f2809bb1527e6470d14: [Backport #20915]</title>
<updated>2024-12-15T06:28:25+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2024-12-15T06:28:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=303a83d35c485db626c57415b344fdd4a8d0d5e5'/>
<id>303a83d35c485db626c57415b344fdd4a8d0d5e5</id>
<content type='text'>
	[Bug #20915] Fix SEGV with `TracePoint#parameters` and aliased C method

	The following snippet results with a SEGV:

	```ruby
	C = Class.new do
	  alias_method :new_to_s, :to_s
	end

	TracePoint.new(:c_call, &amp;:parameters).enable { C.new.new_to_s }
	```

	at MRI 3.3.6 and ruby 3.4.0dev

	The root cause of the issue lies in the `rb_tracearg_parameters` function
	within the `RUBY_EVENT_C_RETURN` branch. Specifically, when the invoked
	method is an alias for a C function,
	`rb_method_entry_without_refinements(..., trace_arg-&gt;called_id, ...)`
	may return NULL. In that case we can fallback to `trace_arg-&gt;id`.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #20915] Fix SEGV with `TracePoint#parameters` and aliased C method

	The following snippet results with a SEGV:

	```ruby
	C = Class.new do
	  alias_method :new_to_s, :to_s
	end

	TracePoint.new(:c_call, &amp;:parameters).enable { C.new.new_to_s }
	```

	at MRI 3.3.6 and ruby 3.4.0dev

	The root cause of the issue lies in the `rb_tracearg_parameters` function
	within the `RUBY_EVENT_C_RETURN` branch. Specifically, when the invoked
	method is an alias for a C function,
	`rb_method_entry_without_refinements(..., trace_arg-&gt;called_id, ...)`
	may return NULL. In that case we can fallback to `trace_arg-&gt;id`.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) b14674b236445fb70f484603e678722760f678f4: [Backport #20194]</title>
<updated>2024-03-31T08:17:34+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2024-03-31T08:17:34+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1b5c74a2408d248f35cb811327dd51f49ee37c9e'/>
<id>1b5c74a2408d248f35cb811327dd51f49ee37c9e</id>
<content type='text'>
	Memory leak with TracePoint on bmethod

	[Bug #20194]

	When disabling the TracePoint on bmethod, the hooks list is not freed.

	For example:

	    obj = Object.new
	    obj.define_singleton_method(:foo) {}
	    bmethod = obj.method(:foo)
	    tp = TracePoint.new(:return) {}

	    10.times do
	      100_000.times do
	        tp.enable(target: bmethod) {}
	      end

	      puts `ps -o rss= -p #{$$}`
	    end

	Before:

	    18208
	    22832
	    26528
	    29728
	    34000
	    37776
	    40864
	    44400
	    47680
	    51504

	After:

	    16688
	    17168
	    17168
	    17248
	    17696
	    17760
	    17824
	    17824
	    17856
	    17920
	---
	 test/ruby/test_settracefunc.rb | 13 +++++++++++++
	 vm_trace.c                     |  1 +
	 2 files changed, 14 insertions(+)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Memory leak with TracePoint on bmethod

	[Bug #20194]

	When disabling the TracePoint on bmethod, the hooks list is not freed.

	For example:

	    obj = Object.new
	    obj.define_singleton_method(:foo) {}
	    bmethod = obj.method(:foo)
	    tp = TracePoint.new(:return) {}

	    10.times do
	      100_000.times do
	        tp.enable(target: bmethod) {}
	      end

	      puts `ps -o rss= -p #{$$}`
	    end

	Before:

	    18208
	    22832
	    26528
	    29728
	    34000
	    37776
	    40864
	    44400
	    47680
	    51504

	After:

	    16688
	    17168
	    17168
	    17248
	    17696
	    17760
	    17824
	    17824
	    17856
	    17920
	---
	 test/ruby/test_settracefunc.rb | 13 +++++++++++++
	 vm_trace.c                     |  1 +
	 2 files changed, 14 insertions(+)
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 837ef8911c638c3e2bdb6af710de7c1fac7b5f90: [Backport #19305]</title>
<updated>2023-01-18T11:15:28+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-01-18T11:15:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d7fb4629b4058eb86be03760e6b9f1f272e44147'/>
<id>d7fb4629b4058eb86be03760e6b9f1f272e44147</id>
<content type='text'>
	Fix crash in TracePoint c_call for removed method

	trace_arg-&gt;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-&gt;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(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Fix crash in TracePoint c_call for removed method

	trace_arg-&gt;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-&gt;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(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>MJIT: Cancel all on disastrous situations (#7019)</title>
<updated>2022-12-24T09:13:40+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-12-24T09:13:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b9332ac8e7126066ac4238443d63eaa4c06789f9'/>
<id>b9332ac8e7126066ac4238443d63eaa4c06789f9</id>
<content type='text'>
I noticed this while running test_yjit with --mjit-call-threshold=1, 
which redefines `Integer#&lt;`. When Ruby is monkey-patched, 
MJIT itself could be broken.

Similarly, Ruby scripts could break MJIT in many different ways. I
prepared the same set of hooks as YJIT so that we could possibly
override it and disable it on those moments. Every constant under
RubyVM::MJIT is private and thus it's an unsupported behavior though.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
I noticed this while running test_yjit with --mjit-call-threshold=1, 
which redefines `Integer#&lt;`. When Ruby is monkey-patched, 
MJIT itself could be broken.

Similarly, Ruby scripts could break MJIT in many different ways. I
prepared the same set of hooks as YJIT so that we could possibly
override it and disable it on those moments. Every constant under
RubyVM::MJIT is private and thus it's an unsupported behavior though.</pre>
</div>
</content>
</entry>
<entry>
<title>Make sure TracePoint#binding returns nil for c_call/c_return events</title>
<updated>2022-12-22T05:02:43+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2022-12-22T05:02:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4213f42555a62b565ff99e0ad3e7d3c7f5495180'/>
<id>4213f42555a62b565ff99e0ad3e7d3c7f5495180</id>
<content type='text'>
This makes sure the method returns nil for these events, as
described in NEWS, even if the TracePoint could create a binding.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This makes sure the method returns nil for these events, as
described in NEWS, even if the TracePoint could create a binding.</pre>
</div>
</content>
</entry>
<entry>
<title>Using UNDEF_P macro</title>
<updated>2022-11-16T09:58:33+00:00</updated>
<author>
<name>S-H-GAMELINKS</name>
<email>gamelinks007@gmail.com</email>
</author>
<published>2022-11-15T04:24:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6'/>
<id>1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Refactor update_global_event_hook</title>
<updated>2022-11-13T23:13:44+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-13T23:13:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=dc5e2eaab6a82d31992127e4a3ba4028824d7b92'/>
<id>dc5e2eaab6a82d31992127e4a3ba4028824d7b92</id>
<content type='text'>
It seems more readable to put JIT invalidation code together.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It seems more readable to put JIT invalidation code together.
</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Fix invalidation for c_call and c_return (#6719)</title>
<updated>2022-11-13T17:51:19+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2022-11-13T17:51:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=bc8ba244b8524c8537eda4ca79f880312c8f4528'/>
<id>bc8ba244b8524c8537eda4ca79f880312c8f4528</id>
<content type='text'>
Follow-up for 2b8191bdad7545b71f270d2b25a34cd2b3afa02f. Since that
commit, we stopped doing code invalidation the second time the call and
return events are enabled. We need to do it every time these events are
enabled because we might have generated code while these events are
disabled.

Also rename locals and edit comments to make it more clear that the iseq
rewrite code path only happens the first time a particular iseq trace
event is enabled.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Follow-up for 2b8191bdad7545b71f270d2b25a34cd2b3afa02f. Since that
commit, we stopped doing code invalidation the second time the call and
return events are enabled. We need to do it every time these events are
enabled because we might have generated code while these events are
disabled.

Also rename locals and edit comments to make it more clear that the iseq
rewrite code path only happens the first time a particular iseq trace
event is enabled.</pre>
</div>
</content>
</entry>
<entry>
<title>YJIT: Invalidate JIT code only for ISEQ_TRACE_EVENTS (#6695)</title>
<updated>2022-11-10T22:12:38+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-11-10T22:12:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2b8191bdad7545b71f270d2b25a34cd2b3afa02f'/>
<id>2b8191bdad7545b71f270d2b25a34cd2b3afa02f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Expand tabs [ci skip]</title>
<updated>2022-07-21T16:42:04+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-07-21T16:23:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5b21e94bebed90180d8ff63dad03b8b948361089'/>
<id>5b21e94bebed90180d8ff63dad03b8b948361089</id>
<content type='text'>
[Misc #18891]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Misc #18891]
</pre>
</div>
</content>
</entry>
</feed>
