<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_hash.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>merge revision(s) 056497319658cbefe22351c6ec5c9fa6e4df72bd: [Backport #21357]</title>
<updated>2025-07-14T20:52:11+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-07-14T20:52:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1bdae3404b2918a8823d2fbac2f9e30f778aa1c9'/>
<id>1bdae3404b2918a8823d2fbac2f9e30f778aa1c9</id>
<content type='text'>
	[Bug #21357] Fix crash in Hash#merge with block

	Prior to https://github.com/ruby/ruby/commit/49b306ecb9e2e9e06e0b1590bacc5f4b38169c3c
	the `optional_arg` passed from `rb_hash_update_block_i` to `tbl_update`
	was a hash value (i.e. a VALUE). After that commit it changed to an
	`update_call_args`.

	If the block sets or changes the value, `tbl_update_modify` will set the
	`arg.value` back to an actual value and we won't crash. But in the case
	where the block returns the original value we end up calling
	`RB_OBJ_WRITTEN` with the `update_call_args` which is not expected and
	may crash.

	`arg.value` appears to only be used to pass to `RB_OBJ_WRITTEN` (others
	who need the `update_call_args` get it from `arg.arg`), so I don't think
	it needs to be set to anything upfront. And `tbl_update_modify` will set
	the `arg.value` in the cases we need the write barrier.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #21357] Fix crash in Hash#merge with block

	Prior to https://github.com/ruby/ruby/commit/49b306ecb9e2e9e06e0b1590bacc5f4b38169c3c
	the `optional_arg` passed from `rb_hash_update_block_i` to `tbl_update`
	was a hash value (i.e. a VALUE). After that commit it changed to an
	`update_call_args`.

	If the block sets or changes the value, `tbl_update_modify` will set the
	`arg.value` back to an actual value and we won't crash. But in the case
	where the block returns the original value we end up calling
	`RB_OBJ_WRITTEN` with the `update_call_args` which is not expected and
	may crash.

	`arg.value` appears to only be used to pass to `RB_OBJ_WRITTEN` (others
	who need the `update_call_args` get it from `arg.arg`), so I don't think
	it needs to be set to anything upfront. And `tbl_update_modify` will set
	the `arg.value` in the cases we need the write barrier.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 49b306ecb9e2e9e06e0b1590bacc5f4b38169c3c: [Backport #21333]</title>
<updated>2025-07-14T20:49:12+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-07-14T20:49:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=247b452af3ace2000d27475a0cb05ebecf3bb29c'/>
<id>247b452af3ace2000d27475a0cb05ebecf3bb29c</id>
<content type='text'>
	[Bug #21333] Prohibit hash modification inside Hash#update block
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #21333] Prohibit hash modification inside Hash#update block
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #21331] Prohibit hash modification during stlike loop</title>
<updated>2025-05-14T03:01:10+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-05-14T01:37:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a21b88a6081edaa73549caa285d4f0d26d1f8462'/>
<id>a21b88a6081edaa73549caa285d4f0d26d1f8462</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Revert "[Bug #21331] Prohibit modification during stlike loop"</title>
<updated>2025-05-14T03:00:53+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2025-05-14T01:23:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fbcb3271857115596d9a2760bb117d196d7f57a9'/>
<id>fbcb3271857115596d9a2760bb117d196d7f57a9</id>
<content type='text'>
This reverts commit bb180b87b43c45e17ff49735a26d7a188d5c8396, which
caused "malloc during GC" error on wasm.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This reverts commit bb180b87b43c45e17ff49735a26d7a188d5c8396, which
caused "malloc during GC" error on wasm.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) bb180b87b43c45e17ff49735a26d7a188d5c8396: [Backport #21331]</title>
<updated>2025-05-14T00:14:49+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-05-14T00:14:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=862480a316c014d2b4659b22cd12e311c0810105'/>
<id>862480a316c014d2b4659b22cd12e311c0810105</id>
<content type='text'>
	[Bug #21331] Prohibit modification during stlike loop
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #21331] Prohibit modification during stlike loop
</pre>
</div>
</content>
</entry>
<entry>
<title>Replace tombstone when converting AR to ST hash</title>
<updated>2025-03-05T23:15:45+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2025-03-04T20:54:33+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=698741d73a0e6c998fb47297ce7b129366b4835b'/>
<id>698741d73a0e6c998fb47297ce7b129366b4835b</id>
<content type='text'>
[Bug #21170]

st_table reserves -1 as a special hash value to indicate that an entry
has been deleted. So that that's a valid value to be returned from the
hash function, do_hash replaces -1 with 0 so that it is not mistaken for
the sentinel.

Previously, when upgrading an AR table to an ST table,
rb_st_add_direct_with_hash was used which did not perform the same
conversion, this could lead to a hash in a broken state where one if its
entries which was supposed to exist being marked as a tombstone.

The hash could then become further corrupted when the ST table required
resizing as the falsely tombstoned entry would be skipped but it would
be counted in num entries, leading to an uninitialized entry at index
15.

In most cases this will be really rare, unless using a very poorly
implemented custom hash function.

This also adds two debug assertions, one that st_add_direct_with_hash
does not receive the reserved hash value, and a second in
rebuild_table_with, which ensures that after we rebuild/compact a table
it contains the expected number of elements.

Co-authored-by: Alan Wu &lt;alanwu@ruby-lang.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #21170]

st_table reserves -1 as a special hash value to indicate that an entry
has been deleted. So that that's a valid value to be returned from the
hash function, do_hash replaces -1 with 0 so that it is not mistaken for
the sentinel.

Previously, when upgrading an AR table to an ST table,
rb_st_add_direct_with_hash was used which did not perform the same
conversion, this could lead to a hash in a broken state where one if its
entries which was supposed to exist being marked as a tombstone.

The hash could then become further corrupted when the ST table required
resizing as the falsely tombstoned entry would be skipped but it would
be counted in num entries, leading to an uninitialized entry at index
15.

In most cases this will be really rare, unless using a very poorly
implemented custom hash function.

This also adds two debug assertions, one that st_add_direct_with_hash
does not receive the reserved hash value, and a second in
rebuild_table_with, which ensures that after we rebuild/compact a table
it contains the expected number of elements.

Co-authored-by: Alan Wu &lt;alanwu@ruby-lang.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Prevent a warning: setting Encoding.default_external</title>
<updated>2024-11-25T06:45:00+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2024-11-25T06:44:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f78f1e927fd18fffb24289065b3dec8ec6c2bd24'/>
<id>f78f1e927fd18fffb24289065b3dec8ec6c2bd24</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Prevent method redefinition warnings in test</title>
<updated>2024-11-07T04:18:57+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2024-11-07T04:18:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f87ec81e087c14e3bff1f67177619a148caa6a11'/>
<id>f87ec81e087c14e3bff1f67177619a148caa6a11</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Update ruby test for colon-style hash inspect</title>
<updated>2024-10-03T09:47:09+00:00</updated>
<author>
<name>tompng</name>
<email>tomoyapenguin@gmail.com</email>
</author>
<published>2024-06-07T15:23:12+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7237af75d2aa700454fbaba9bda7a9283413d903'/>
<id>7237af75d2aa700454fbaba9bda7a9283413d903</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Hash#inspect with colon style</title>
<updated>2024-10-03T09:47:09+00:00</updated>
<author>
<name>tompng</name>
<email>tomoyapenguin@gmail.com</email>
</author>
<published>2024-06-06T17:05:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a8a059125314a411eaf879a9fbfdc68d6c01a667'/>
<id>a8a059125314a411eaf879a9fbfdc68d6c01a667</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
