<feed xmlns='http://www.w3.org/2005/Atom'>
<title>delta/ruby.git/test/ruby/test_settracefunc.rb, branch ruby_3_2</title>
<subtitle>github.com: ruby/ruby.git
</subtitle>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/'/>
<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='http://trove.baserock.org/cgit/delta/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>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='http://trove.baserock.org/cgit/delta/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>Implement Queue#pop(timeout: sec)</title>
<updated>2022-08-02T09:04:28+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>jean.boussier@gmail.com</email>
</author>
<published>2022-07-26T15:40:00+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=e3aabe93aae87a60ba7b8f1a0fd590534647e352'/>
<id>e3aabe93aae87a60ba7b8f1a0fd590534647e352</id>
<content type='text'>
[Feature #18774]

As well as `SizedQueue#pop(timeout: sec)`

If both `non_block=true` and `timeout:` are supplied, ArgumentError
is raised.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Feature #18774]

As well as `SizedQueue#pop(timeout: sec)`

If both `non_block=true` and `timeout:` are supplied, ArgumentError
is raised.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix infinite loop when b_return TracePoint throws</title>
<updated>2022-06-22T12:30:39+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2021-07-08T22:23:39+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=744d17ff6c33b09334508e8110007ea2a82252f5'/>
<id>744d17ff6c33b09334508e8110007ea2a82252f5</id>
<content type='text'>
Previously, we didn't pop the frame that runs the TracePoint hook for
b_return events for blocks running as methods (bmethods). In case the
hook raises, that formed an infinite loop during stack unwinding in
hook_before_rewind().

[Bug #18060]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously, we didn't pop the frame that runs the TracePoint hook for
b_return events for blocks running as methods (bmethods). In case the
hook raises, that formed an infinite loop during stack unwinding in
hook_before_rewind().

[Bug #18060]
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix nested bmethod TracePoint and memory leak</title>
<updated>2022-06-10T01:10:27+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2021-07-14T23:44:26+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=e75cb61d4645b9833b14a0cc4190cceffc9b6551'/>
<id>e75cb61d4645b9833b14a0cc4190cceffc9b6551</id>
<content type='text'>
df317151a5b4e0c5a30fcc321a9dc6abad63f7ed removed the code to free
rb_hook_list_t, so repeated targeting of the same bmethod started
to leak the hook list. You can observe how the maximum memory use
scales with input size in the following script with `/usr/bin/time -v`.

```ruby
o = Object.new
o.define_singleton_method(:foo) {}
trace = TracePoint.new(:return) {}

bmethod = o.method(:foo)

ARGV.first.to_i.times { trace.enable(target:bmethod){} }
4.times {GC.start}
```

After this change the maximum doesn't grow as quickly.

To plug the leak, check whether the hook list is already allocated
when enabling the targeting TracePoint for the bmethod. This fix
also allows multiple TracePoints to target the same bmethod, similar
to other valid TracePoint targets.

Finally, free the rb_hook_list_t struct when freeing the method
definition it lives on. Freeing in the GC is a good way to avoid
lifetime problems similar to the one fixed in df31715.

[Bug #18031]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
df317151a5b4e0c5a30fcc321a9dc6abad63f7ed removed the code to free
rb_hook_list_t, so repeated targeting of the same bmethod started
to leak the hook list. You can observe how the maximum memory use
scales with input size in the following script with `/usr/bin/time -v`.

```ruby
o = Object.new
o.define_singleton_method(:foo) {}
trace = TracePoint.new(:return) {}

bmethod = o.method(:foo)

ARGV.first.to_i.times { trace.enable(target:bmethod){} }
4.times {GC.start}
```

After this change the maximum doesn't grow as quickly.

To plug the leak, check whether the hook list is already allocated
when enabling the targeting TracePoint for the bmethod. This fix
also allows multiple TracePoints to target the same bmethod, similar
to other valid TracePoint targets.

Finally, free the rb_hook_list_t struct when freeing the method
definition it lives on. Freeing in the GC is a good way to avoid
lifetime problems similar to the one fixed in df31715.

[Bug #18031]
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix use-after-free with interacting TracePoints</title>
<updated>2022-05-30T17:54:22+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2022-04-29T22:54:16+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=a687756284187887835aa345adc89b2718054e4a'/>
<id>a687756284187887835aa345adc89b2718054e4a</id>
<content type='text'>
`vm_trace_hook()` runs global hooks before running local hooks.
Previously, we read the local hook list before running the global hooks
which led to use-after-free when a global hook frees the local hook
list. A global hook can do this by disabling a local TracePoint, for
example.

Delay local hook list loading until after running the global hooks.

Issue discovered by Jeremy Evans in GH-5862.

[Bug #18730]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`vm_trace_hook()` runs global hooks before running local hooks.
Previously, we read the local hook list before running the global hooks
which led to use-after-free when a global hook frees the local hook
list. A global hook can do this by disabling a local TracePoint, for
example.

Delay local hook list loading until after running the global hooks.

Issue discovered by Jeremy Evans in GH-5862.

[Bug #18730]
</pre>
</div>
</content>
</entry>
<entry>
<title>Raise RuntimeError if Kernel#binding is called from a non-Ruby frame</title>
<updated>2022-04-07T02:14:03+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2022-04-07T02:14:03+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=0b091fdac6ceb33b7379ceddc9a49a79d0e158b2'/>
<id>0b091fdac6ceb33b7379ceddc9a49a79d0e158b2</id>
<content type='text'>
Check whether the current or previous frame is a Ruby frame in
call_trace_func and rb_tracearg_binding before attempting to
create a binding for the frame.

Fixes [Bug #18487]

Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Check whether the current or previous frame is a Ruby frame in
call_trace_func and rb_tracearg_binding before attempting to
create a binding for the frame.

Fixes [Bug #18487]

Co-authored-by: Alan Wu &lt;XrXr@users.noreply.github.com&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "Raise RuntimeError if Kernel#binding is called from a non-Ruby frame"</title>
<updated>2022-04-01T14:22:49+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2022-04-01T14:22:49+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=d1d48cb690fdad855da94b2a2d11721428bc06ba'/>
<id>d1d48cb690fdad855da94b2a2d11721428bc06ba</id>
<content type='text'>
This reverts commit 343ea9967e4a6b279eed6bd8e81ad0bdc747f254.

This causes an assertion failure with -DRUBY_DEBUG=1 -DRGENGC_CHECK_MODE=2
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit 343ea9967e4a6b279eed6bd8e81ad0bdc747f254.

This causes an assertion failure with -DRUBY_DEBUG=1 -DRGENGC_CHECK_MODE=2
</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid trace events in implementation of TracePoint#enable</title>
<updated>2022-03-30T01:14:33+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-12-27T22:08:59+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=3c6a0033e3dc7da2898232a2efc7367ae6fc536a'/>
<id>3c6a0033e3dc7da2898232a2efc7367ae6fc536a</id>
<content type='text'>
This is more backwards compatible, and should fix issues with
power_assert.

Unfortunately, it requires using a sentinel value as the default
value of target_thread, instead of the more natural expression
used in the original approach.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This is more backwards compatible, and should fix issues with
power_assert.

Unfortunately, it requires using a sentinel value as the default
value of target_thread, instead of the more natural expression
used in the original approach.
</pre>
</div>
</content>
</entry>
<entry>
<title>Make TracePoint#enable with block target current thread by default</title>
<updated>2022-03-30T01:14:33+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-12-27T20:52:04+00:00</published>
<link rel='alternate' type='text/html' href='http://trove.baserock.org/cgit/delta/ruby.git/commit/?id=9c1d32a7ada794ecd0356d56f7be3cdf3982d8ac'/>
<id>9c1d32a7ada794ecd0356d56f7be3cdf3982d8ac</id>
<content type='text'>
If TracePoint#enable is passed a block, it previously started
the trace on all threads.  This changes it to trace only the
current thread by default.  To limit the scope of the change,
the current thread is only used by default if target and
target_line are both nil.  You can pass target_thread: nil
to enable tracing on all threads, to get the previous
default behavior.

Fixes [Bug #16889]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If TracePoint#enable is passed a block, it previously started
the trace on all threads.  This changes it to trace only the
current thread by default.  To limit the scope of the change,
the current thread is only used by default if target and
target_line are both nil.  You can pass target_thread: nil
to enable tracing on all threads, to get the previous
default behavior.

Fixes [Bug #16889]
</pre>
</div>
</content>
</entry>
</feed>
