<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/vm_backtrace.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>Make rb_profile_frames return 0 for NULL ec</title>
<updated>2023-12-21T23:23:19+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2023-12-20T21:54:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ffa5f16273f46c97bfca56e4549b0b38b9322d63'/>
<id>ffa5f16273f46c97bfca56e4549b0b38b9322d63</id>
<content type='text'>
When using M:N threads, EC is set to NULL in the shared native thread
when nothing is scheduled. This previously caused a segfault when we try
to examine the EC.

Returning 0 instead means we may miss profiling information, but a
profiler relying on this isn't thread aware anyways, and observing that
"nothing" is running is probably correct.

Fixes [Bug #20017]

Co-authored-by: Dustin Brown &lt;dbrown9@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When using M:N threads, EC is set to NULL in the shared native thread
when nothing is scheduled. This previously caused a segfault when we try
to examine the EC.

Returning 0 instead means we may miss profiling information, but a
profiler relying on this isn't thread aware anyways, and observing that
"nothing" is running is probably correct.

Fixes [Bug #20017]

Co-authored-by: Dustin Brown &lt;dbrown9@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Get rid of useless dsize functions</title>
<updated>2023-11-21T14:15:03+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>byroot@ruby-lang.org</email>
</author>
<published>2023-11-21T11:09:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b4f551686b973b03665bcaa3ecf128c0a87ff58b'/>
<id>b4f551686b973b03665bcaa3ecf128c0a87ff58b</id>
<content type='text'>
If we always return 0, we might as well not define
the function at all.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
If we always return 0, we might as well not define
the function at all.
</pre>
</div>
</content>
</entry>
<entry>
<title>Embed Thread::Backtrace::Location into Thread::Backtrace</title>
<updated>2023-11-20T14:23:56+00:00</updated>
<author>
<name>Étienne Barrié</name>
<email>etienne.barrie@gmail.com</email>
</author>
<published>2023-11-17T09:24:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=46ef74f270d022068def440ab6208e1648030847'/>
<id>46ef74f270d022068def440ab6208e1648030847</id>
<content type='text'>
Co-authored-by: Jean Boussier &lt;byroot@ruby-lang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Co-authored-by: Jean Boussier &lt;byroot@ruby-lang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Embed Backtrace objects</title>
<updated>2023-11-10T14:56:42+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>byroot@ruby-lang.org</email>
</author>
<published>2023-11-10T10:56:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3b69637eba307a6e7a2951be0147e4811b77b535'/>
<id>3b69637eba307a6e7a2951be0147e4811b77b535</id>
<content type='text'>
rb_backtrace_t is 32B, so it fits well in a 80B slot.

There is some unused spaces but given Backtrace objects are
rarely held onto it should be inconsequential and avoid
the malloc churn.

Co-Authored-By: Étienne Barrié &lt;etienne.barrie@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
rb_backtrace_t is 32B, so it fits well in a 80B slot.

There is some unused spaces but given Backtrace objects are
rarely held onto it should be inconsequential and avoid
the malloc churn.

Co-Authored-By: Étienne Barrié &lt;etienne.barrie@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Embed Backtrace::Location objects</title>
<updated>2023-11-10T14:56:22+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>byroot@ruby-lang.org</email>
</author>
<published>2023-11-10T09:21:28+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a2442e91fded557fe79a49a86b84565ee66e34cc'/>
<id>a2442e91fded557fe79a49a86b84565ee66e34cc</id>
<content type='text'>
The struct is 16B, so they will use the 80B size pool, so on paper it
wastes 80 - 32 - 16 = 52B, however most malloc implementations will
either pad sizes or use an extra 16B for each segment, so in practice
the waste isn't that big. Also `Backtrace::Location` are rarely held
on for long, so avoiding the malloc churn help performance.

Co-Authored-By: Étienne Barrié &lt;etienne.barrie@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The struct is 16B, so they will use the 80B size pool, so on paper it
wastes 80 - 32 - 16 = 52B, however most malloc implementations will
either pad sizes or use an extra 16B for each segment, so in practice
the waste isn't that big. Also `Backtrace::Location` are rarely held
on for long, so avoiding the malloc churn help performance.

Co-Authored-By: Étienne Barrié &lt;etienne.barrie@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>[Feature #10602] Add new API rb_profile_thread_frames()</title>
<updated>2023-10-31T02:16:18+00:00</updated>
<author>
<name>Daisuke Aritomo</name>
<email>osyoyu@osyoyu.com</email>
</author>
<published>2023-09-29T06:35:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4adf418be963b3554962b2f27057be81486c57d9'/>
<id>4adf418be963b3554962b2f27057be81486c57d9</id>
<content type='text'>
Add a new API rb_profile_thread_frames(), which is essentialy a
per-thread version of rb_profile_frames().

While the original rb_profile_frames() always returns results about the
current active thread obtained by GET_EC(), this new API takes a Thread
to be profiled as an argument.

This should come in handy when profiling I/O-bound programs such as
webapps, since this new API allows us to learn about Threads performing
I/O (which do not have the GVL).

Profiling worker threads (such as Sidekiq workers) may be another
application.

Implements [Feature #10602]

Co-authored-by: Mike Perham &lt;mike@perham.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Add a new API rb_profile_thread_frames(), which is essentialy a
per-thread version of rb_profile_frames().

While the original rb_profile_frames() always returns results about the
current active thread obtained by GET_EC(), this new API takes a Thread
to be profiled as an argument.

This should come in handy when profiling I/O-bound programs such as
webapps, since this new API allows us to learn about Threads performing
I/O (which do not have the GVL).

Profiling worker threads (such as Sidekiq workers) may be another
application.

Implements [Feature #10602]

Co-authored-by: Mike Perham &lt;mike@perham.net&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Dump backtraces to an arbitrary stream</title>
<updated>2023-09-25T13:57:28+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-07-31T18:04:42+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ac244938e8b97c8bd42d1dc8ed820091e6ef5537'/>
<id>ac244938e8b97c8bd42d1dc8ed820091e6ef5537</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Return line 0 for JIT frames</title>
<updated>2023-09-15T16:01:02+00:00</updated>
<author>
<name>Aaron Patterson</name>
<email>tenderlove@ruby-lang.org</email>
</author>
<published>2023-09-11T21:11:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a1dc1a3de9683daf5a543d6f618e17aabfcb8708'/>
<id>a1dc1a3de9683daf5a543d6f618e17aabfcb8708</id>
<content type='text'>
Frames pushed by YJIT have an unreliable PC.  The PC could be garbage,
and if we try to read the line number with a garbage PC, then the
program can crash.

This commit returns line 0 for programs where there is a `jit_return`
function.  If `jit_return` has been set then this frame was pushed by
the JIT, and we cannot trust the PC.

Here is a debugger session for a program that crashed due to a broken
PC:

```
(lldb) p ruby_current_vm_ptr-&gt;ractor.main_thread-&gt;ec-&gt;cfp-&gt;iseq-&gt;body-&gt;iseq_encoded
(VALUE *) $0 = 0x0000000118a30e00
(lldb) p/x ruby_current_vm_ptr-&gt;ractor.main_thread-&gt;ec-&gt;cfp-&gt;pc
(const VALUE *) $1 = 0x0000600000b02d00
(lldb) p/x ruby_current_vm_ptr-&gt;ractor.main_thread-&gt;ec-&gt;cfp-&gt;jit_return
(void *) $2 = 0x000000010622942c
```

You can see the PC is completely out of range, but there is a
`jit_return` pointer so we can avoid this crash.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Frames pushed by YJIT have an unreliable PC.  The PC could be garbage,
and if we try to read the line number with a garbage PC, then the
program can crash.

This commit returns line 0 for programs where there is a `jit_return`
function.  If `jit_return` has been set then this frame was pushed by
the JIT, and we cannot trust the PC.

Here is a debugger session for a program that crashed due to a broken
PC:

```
(lldb) p ruby_current_vm_ptr-&gt;ractor.main_thread-&gt;ec-&gt;cfp-&gt;iseq-&gt;body-&gt;iseq_encoded
(VALUE *) $0 = 0x0000000118a30e00
(lldb) p/x ruby_current_vm_ptr-&gt;ractor.main_thread-&gt;ec-&gt;cfp-&gt;pc
(const VALUE *) $1 = 0x0000600000b02d00
(lldb) p/x ruby_current_vm_ptr-&gt;ractor.main_thread-&gt;ec-&gt;cfp-&gt;jit_return
(void *) $2 = 0x000000010622942c
```

You can see the PC is completely out of range, but there is a
`jit_return` pointer so we can avoid this crash.
</pre>
</div>
</content>
</entry>
<entry>
<title>Don't check for null pointer in calls to free</title>
<updated>2023-06-30T13:13:31+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-06-29T20:31:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=58386814a7c7275f66ffa111175fca2fe307a1b5'/>
<id>58386814a7c7275f66ffa111175fca2fe307a1b5</id>
<content type='text'>
According to the C99 specification section 7.20.3.2 paragraph 2:

&gt; If ptr is a null pointer, no action occurs.

So we do not need to check that the pointer is a null pointer.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
According to the C99 specification section 7.20.3.2 paragraph 2:

&gt; If ptr is a null pointer, no action occurs.

So we do not need to check that the pointer is a null pointer.
</pre>
</div>
</content>
</entry>
<entry>
<title>Suppress -Wsign-compare warning</title>
<updated>2023-03-23T14:31:46+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-03-23T12:51:18+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b738cb01b66c7b80364f9044b64097d690e49fc7'/>
<id>b738cb01b66c7b80364f9044b64097d690e49fc7</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
