<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/vm_trace.c, branch v3_3_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Backport WASI setjmp handler memory leak fixes to Ruby 3.3</title>
<updated>2025-10-11T09:27:37+00:00</updated>
<author>
<name>刘皓</name>
<email>whiteaxe@tuta.io</email>
</author>
<published>2025-10-09T00:45:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7e31d3c0229095b6b256ba04288869a6373938b6'/>
<id>7e31d3c0229095b6b256ba04288869a6373938b6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 660b995365f719fa59ed6f2809bb1527e6470d14: [Backport #20915]</title>
<updated>2025-01-15T01:51:27+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-01-15T01:51:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=745fe4cf7e0c297879b46045a4838b3e5e2dfeb9'/>
<id>745fe4cf7e0c297879b46045a4838b3e5e2dfeb9</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] (#10295)</title>
<updated>2024-03-20T11:05:08+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-20T11:05:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=23bfe6218a690bbde5143e26bc6fb243347fb4b3'/>
<id>23bfe6218a690bbde5143e26bc6fb243347fb4b3</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>Remove EC argument from clean_hooks_check</title>
<updated>2023-12-23T02:07:22+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2023-12-16T09:34:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=697a096c9b0d8c153cb5d99affb6b5673b7c4210'/>
<id>697a096c9b0d8c153cb5d99affb6b5673b7c4210</id>
<content type='text'>
This argument doesn't seem used anymore. Since we want to free these
objects during VM destruction when RUBY_FREE_AT_EXIT is set they must
work without an EC.

This avoids a use-after-free running `RUBY_FREE_AT_EXIT=1 ./miniruby -e ''`
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This argument doesn't seem used anymore. Since we want to free these
objects during VM destruction when RUBY_FREE_AT_EXIT is set they must
work without an EC.

This avoids a use-after-free running `RUBY_FREE_AT_EXIT=1 ./miniruby -e ''`
</pre>
</div>
</content>
</entry>
<entry>
<title>Refactor local variable names in postponed_job methods</title>
<updated>2023-12-13T02:35:05+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>ktsanaktsidis@zendesk.com</email>
</author>
<published>2023-12-11T04:00:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4eefab592ac068acfd06fb9422f75a7786fbb855'/>
<id>4eefab592ac068acfd06fb9422f75a7786fbb855</id>
<content type='text'>
Just removes the unneeded `prereg_` prefix from a few local var names.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Just removes the unneeded `prereg_` prefix from a few local var names.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #19114] Fix for multiple calls of TracePoint#enable</title>
<updated>2023-12-12T17:36:37+00:00</updated>
<author>
<name>Kouhei Yanagita</name>
<email>yanagi@shakenbu.org</email>
</author>
<published>2023-11-22T09:12:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=06e2fbb8260022de8532d2e940fc69e8ea413679'/>
<id>06e2fbb8260022de8532d2e940fc69e8ea413679</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>add `flags` to `rb_postponed_job_preregister`</title>
<updated>2023-12-10T06:39:06+00:00</updated>
<author>
<name>Koichi Sasada</name>
<email>ko1@atdot.net</email>
</author>
<published>2023-12-09T16:47:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c4c39082af3520cd96aefc2219a7037865f3f710'/>
<id>c4c39082af3520cd96aefc2219a7037865f3f710</id>
<content type='text'>
for future extensions.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
for future extensions.
</pre>
</div>
</content>
</entry>
<entry>
<title>Change the semantics of rb_postponed_job_register</title>
<updated>2023-12-10T06:00:37+00:00</updated>
<author>
<name>KJ Tsanaktsidis</name>
<email>kj@kjtsanaktsidis.id.au</email>
</author>
<published>2023-11-19T11:54:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f8effa209adb3ce050c100ffaffe6f3cc1508185'/>
<id>f8effa209adb3ce050c100ffaffe6f3cc1508185</id>
<content type='text'>
Our current implementation of rb_postponed_job_register suffers from
some safety issues that can lead to interpreter crashes (see bug #1991).
Essentially, the issue is that jobs can be called with the wrong
arguments.

We made two attempts to fix this whilst keeping the promised semantics,
but:
  * The first one involved masking/unmasking when flushing jobs, which
    was believed to be too expensive
  * The second one involved a lock-free, multi-producer, single-consumer
    ringbuffer, which was too complex

The critical insight behind this third solution is that essentially the
only user of these APIs are a) internal, or b) profiling gems.

For a), none of the usages actually require variable data; they will
work just fine with the preregistration interface.

For b), generally profiling gems only call a single callback with a
single piece of data (which is actually usually just zero) for the life
of the program. The ringbuffer is complex because it needs to support
multi-word inserts of job &amp; data (which can't be atomic); but nobody
actually even needs that functionality, really.

So, this comit:
  * Introduces a pre-registration API for jobs, with a GVL-requiring
    rb_postponed_job_prereigster, which returns a handle which can be
    used with an async-signal-safe rb_postponed_job_trigger.
  * Deprecates rb_postponed_job_register (and re-implements it on top of
    the preregister function for compatability)
  * Moves all the internal usages of postponed job register
    pre-registration
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Our current implementation of rb_postponed_job_register suffers from
some safety issues that can lead to interpreter crashes (see bug #1991).
Essentially, the issue is that jobs can be called with the wrong
arguments.

We made two attempts to fix this whilst keeping the promised semantics,
but:
  * The first one involved masking/unmasking when flushing jobs, which
    was believed to be too expensive
  * The second one involved a lock-free, multi-producer, single-consumer
    ringbuffer, which was too complex

The critical insight behind this third solution is that essentially the
only user of these APIs are a) internal, or b) profiling gems.

For a), none of the usages actually require variable data; they will
work just fine with the preregistration interface.

For b), generally profiling gems only call a single callback with a
single piece of data (which is actually usually just zero) for the life
of the program. The ringbuffer is complex because it needs to support
multi-word inserts of job &amp; data (which can't be atomic); but nobody
actually even needs that functionality, really.

So, this comit:
  * Introduces a pre-registration API for jobs, with a GVL-requiring
    rb_postponed_job_prereigster, which returns a handle which can be
    used with an async-signal-safe rb_postponed_job_trigger.
  * Deprecates rb_postponed_job_register (and re-implements it on top of
    the preregister function for compatability)
  * Moves all the internal usages of postponed job register
    pre-registration
</pre>
</div>
</content>
</entry>
<entry>
<title>Implement TracePoint on VWA</title>
<updated>2023-11-22T21:01:00+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-11-22T14:24:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5672fb63d21ca8311513c44a82ffe5a0c8f55240'/>
<id>5672fb63d21ca8311513c44a82ffe5a0c8f55240</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Implement Write Barriers on TracePoint</title>
<updated>2023-11-22T13:38:36+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-11-21T21:33:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0f24ecf17ae43a9c2501d0f3e5b2a6d829fcdd7f'/>
<id>0f24ecf17ae43a9c2501d0f3e5b2a6d829fcdd7f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
