<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_objectspace.rb, branch v3_4_9</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Remove a puts in test_finalizer_thread_raise</title>
<updated>2024-10-15T13:10:35+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-10-11T15:23:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3da3cabf982eaa4d2c9732651f6a9e18ffd0aba3'/>
<id>3da3cabf982eaa4d2c9732651f6a9e18ffd0aba3</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Replace all GC.disable with EnvUtil.without_gc</title>
<updated>2024-09-17T14:34:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-09-16T19:29:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0160dafc4c52b84bb1f989670b54186505649493'/>
<id>0160dafc4c52b84bb1f989670b54186505649493</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Increase timeout of test_finalizer</title>
<updated>2024-08-14T20:23:22+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-08-14T20:23:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fd974f5d740b9b5af63ecfdef3ee092b69e437a3'/>
<id>fd974f5d740b9b5af63ecfdef3ee092b69e437a3</id>
<content type='text'>
The test is timing out on lpi4a so a longer timeout should fix it.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The test is timing out on lpi4a so a longer timeout should fix it.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix crash when GC runs during finalizers at shutdown</title>
<updated>2024-08-14T17:49:52+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-08-14T15:31:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0610f1b083738bb0a84cede42fda048fa116404e'/>
<id>0610f1b083738bb0a84cede42fda048fa116404e</id>
<content type='text'>
We need to remove from the finalizer_table after running all the
finalizers because GC could trigger during the finalizer which could
reclaim the finalizer table array.

The following code crashes:

    1_000_000.times do
      o = Object.new
      ObjectSpace.define_finalizer(o, proc { })
    end
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We need to remove from the finalizer_table after running all the
finalizers because GC could trigger during the finalizer which could
reclaim the finalizer table array.

The following code crashes:

    1_000_000.times do
      o = Object.new
      ObjectSpace.define_finalizer(o, proc { })
    end
</pre>
</div>
</content>
</entry>
<entry>
<title>Refactor how object IDs work for special consts</title>
<updated>2024-04-12T15:27:08+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-04-11T18:30:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=edec690e0331b5aa851b3a7c9872b2bf92f3cb21'/>
<id>edec690e0331b5aa851b3a7c9872b2bf92f3cb21</id>
<content type='text'>
We don't need to treat static symbols in any special way since they
can't be confused with other special consts or GC managed objects.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We don't need to treat static symbols in any special way since they
can't be confused with other special consts or GC managed objects.
</pre>
</div>
</content>
</entry>
<entry>
<title>Add RVALUE_OVERHEAD and move ractor_belonging_id</title>
<updated>2022-11-21T16:26:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2022-11-18T15:07:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5f95228c76e6f6994eb4149217fe3e38f9ff8a27'/>
<id>5f95228c76e6f6994eb4149217fe3e38f9ff8a27</id>
<content type='text'>
This commit adds RVALUE_OVERHEAD for storing metadata at the end of the
slot. This commit moves the ractor_belonging_id in debug builds from the
flags to RVALUE_OVERHEAD which frees the 16 bits in the headers for
object shapes.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This commit adds RVALUE_OVERHEAD for storing metadata at the end of the
slot. This commit moves the ractor_belonging_id in debug builds from the
flags to RVALUE_OVERHEAD which frees the 16 bits in the headers for
object shapes.
</pre>
</div>
</content>
</entry>
<entry>
<title>Ensure _id2ref finds symbols with the correct type</title>
<updated>2022-07-20T17:38:44+00:00</updated>
<author>
<name>Daniel Colson</name>
<email>danieljamescolson@gmail.com</email>
</author>
<published>2022-07-03T00:28:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=32e406d6d3c3ded9160298c4475c1aa188360b07'/>
<id>32e406d6d3c3ded9160298c4475c1aa188360b07</id>
<content type='text'>
Prior to this commit it was possible to call `ObjectSpace._id2ref` with
an offset static symbol object_id and get back a new, incorrectly tagged
symbol:

```
&gt; sensible_sym = ObjectSpace._id2ref(:a.object_id)
=&gt; :a
&gt; nonsense_sym = ObjectSpace._id2ref(:a.object_id + 40)
=&gt; :a
&gt; sensible_sym == nonsense_sym
=&gt; false
```

`nonsense_sym` ends up tagged with `RUBY_ID_INSTANCE` instead of
`RB_ID_LOCAL`. That means we can do silly things like:

```
&gt; foo = Object.new
&gt; foo.instance_variable_set(:a, 123)
(irb):2:in `instance_variable_set': `a' is not allowed as an instance variable name (NameError)
&gt; foo.instance_variable_set(ObjectSpace._id2ref(:a.object_id + 40), 123)
=&gt; 123
&gt; foo.instance_variables
=&gt; [:a]
```

This was happening because `get_id_entry` ignores the tag bits when
looking up the symbol. So `rb_id2str(symid)` would return a value and
then we'd continue on with the nonsense `symid`.

This commit prevents the situation by checking that the `symid` actually
matches what we get back from `get_id_entry`. Now we get a `RangeError`
for the nonsense id:

```
&gt; ObjectSpace._id2ref(:a.object_id)
=&gt; :a
&gt; ObjectSpace._id2ref(:a.object_id + 40)
(irb):1:in `_id2ref': 0x000000000013f408 is not symbol id value (RangeError)
```

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Prior to this commit it was possible to call `ObjectSpace._id2ref` with
an offset static symbol object_id and get back a new, incorrectly tagged
symbol:

```
&gt; sensible_sym = ObjectSpace._id2ref(:a.object_id)
=&gt; :a
&gt; nonsense_sym = ObjectSpace._id2ref(:a.object_id + 40)
=&gt; :a
&gt; sensible_sym == nonsense_sym
=&gt; false
```

`nonsense_sym` ends up tagged with `RUBY_ID_INSTANCE` instead of
`RB_ID_LOCAL`. That means we can do silly things like:

```
&gt; foo = Object.new
&gt; foo.instance_variable_set(:a, 123)
(irb):2:in `instance_variable_set': `a' is not allowed as an instance variable name (NameError)
&gt; foo.instance_variable_set(ObjectSpace._id2ref(:a.object_id + 40), 123)
=&gt; 123
&gt; foo.instance_variables
=&gt; [:a]
```

This was happening because `get_id_entry` ignores the tag bits when
looking up the symbol. So `rb_id2str(symid)` would return a value and
then we'd continue on with the nonsense `symid`.

This commit prevents the situation by checking that the `symid` actually
matches what we get back from `get_id_entry`. Now we get a `RangeError`
for the nonsense id:

```
&gt; ObjectSpace._id2ref(:a.object_id)
=&gt; :a
&gt; ObjectSpace._id2ref(:a.object_id + 40)
(irb):1:in `_id2ref': 0x000000000013f408 is not symbol id value (RangeError)
```

Co-authored-by: John Hawthorn &lt;jhawthorn@github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix typos</title>
<updated>2021-11-02T10:17:37+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2021-11-02T09:29:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a2024081805af4e729bea029abb7bbe7c383dce2'/>
<id>a2024081805af4e729bea029abb7bbe7c383dce2</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Reenable GC at the end of test</title>
<updated>2021-08-04T20:11:08+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter.zhu@shopify.com</email>
</author>
<published>2021-08-04T19:33:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1fd0a2e4a62b70287dfce5bb1a66656b647d3899'/>
<id>1fd0a2e4a62b70287dfce5bb1a66656b647d3899</id>
<content type='text'>
The test disables GC but never reenables it. Before this patch, running
all tests would have a peak RSS in the main process of &gt;4GB. After this
patch, peak RSS in the main process is &lt;500MB.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The test disables GC but never reenables it. Before this patch, running
all tests would have a peak RSS in the main process of &gt;4GB. After this
patch, peak RSS in the main process is &lt;500MB.
</pre>
</div>
</content>
</entry>
<entry>
<title>Do not check pending interrupts when running finalizers</title>
<updated>2021-07-29T16:44:11+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-04-07T18:32:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=87b327efe6c1f456c43b3f105c7a92a5a7effe93'/>
<id>87b327efe6c1f456c43b3f105c7a92a5a7effe93</id>
<content type='text'>
This fixes cases where exceptions raised using Thread#raise are
swallowed by finalizers and not delivered to the running thread.

This could cause issues with finalizers that rely on pending interrupts,
but that case is expected to be rarer.

Fixes [Bug #13876]
Fixes [Bug #15507]

Co-authored-by: Koichi Sasada &lt;ko1@atdot.net&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes cases where exceptions raised using Thread#raise are
swallowed by finalizers and not delivered to the running thread.

This could cause issues with finalizers that rely on pending interrupts,
but that case is expected to be rarer.

Fixes [Bug #13876]
Fixes [Bug #15507]

Co-authored-by: Koichi Sasada &lt;ko1@atdot.net&gt;
</pre>
</div>
</content>
</entry>
</feed>
