<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/array.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>merge revision(s) c479492a6701dcef3d3a96de8946ecf7beb079d4: [Backport #20427]</title>
<updated>2024-05-29T22:44:55+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2024-05-29T22:44:55+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b44c02ad5a1c5c8c1c62b83eec96cf3a8a2107bc'/>
<id>b44c02ad5a1c5c8c1c62b83eec96cf3a8a2107bc</id>
<content type='text'>
	Resize ary when `Array#sort!` block modifies embedded ary

	In cases where `rb_ary_sort_bang` is called with a block and
	tmp is an embedded array, we need to account for the block
	potentially impacting the capacity of ary.

	ex:
	```
	var_0 = (1..70).to_a
	var_0.sort! do |var_0_block_129, var_1_block_129|
	  var_0.pop
	  var_1_block_129 &lt;=&gt; var_0_block_129
	end.shift(3)
	```

	The above example can put the array into a corrupted state
	resulting in a heap buffer overflow and possible segfault:
	```
	ERROR: AddressSanitizer: heap-buffer-overflow on address [...]
	WRITE of size 560 at 0x60b0000034f0 thread T0 [...]
	```

	This commit adds a conditional to determine when the capacity
	of ary has been modified by the provided block. If this is
	the case, ensure that the capacity of ary is adjusted to
	handle at minimum the len of tmp.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Resize ary when `Array#sort!` block modifies embedded ary

	In cases where `rb_ary_sort_bang` is called with a block and
	tmp is an embedded array, we need to account for the block
	potentially impacting the capacity of ary.

	ex:
	```
	var_0 = (1..70).to_a
	var_0.sort! do |var_0_block_129, var_1_block_129|
	  var_0.pop
	  var_1_block_129 &lt;=&gt; var_0_block_129
	end.shift(3)
	```

	The above example can put the array into a corrupted state
	resulting in a heap buffer overflow and possible segfault:
	```
	ERROR: AddressSanitizer: heap-buffer-overflow on address [...]
	WRITE of size 560 at 0x60b0000034f0 thread T0 [...]
	```

	This commit adds a conditional to determine when the capacity
	of ary has been modified by the provided block. If this is
	the case, ensure that the capacity of ary is adjusted to
	handle at minimum the len of tmp.
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove useless `#if 1` in array.c</title>
<updated>2023-12-23T14:51:30+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-12-23T14:51:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=47f33c38481d79563271f042946d0f3165d8b638'/>
<id>47f33c38481d79563271f042946d0f3165d8b638</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix ary_make_partial_step for compaction</title>
<updated>2023-12-21T15:39:03+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-12-19T01:55:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e191bf42d2077a025c21888573f8b81688e5ea28'/>
<id>e191bf42d2077a025c21888573f8b81688e5ea28</id>
<content type='text'>
ary could change embeddedness due to compaction, so we should only get
the pointer after allocations.

The included test was crashing with:

    TestArray#test_slice_gc_compact_stress
    ruby/lib/pp.rb:192: [BUG] Segmentation fault at 0x0000000000000038
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
ary could change embeddedness due to compaction, so we should only get
the pointer after allocations.

The included test was crashing with:

    TestArray#test_slice_gc_compact_stress
    ruby/lib/pp.rb:192: [BUG] Segmentation fault at 0x0000000000000038
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] No document for internal or debug methods</title>
<updated>2023-12-18T11:17:45+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-12-18T10:57:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=40fc9b070ca68e0bd1d57e4dd712172e2faeaa2b'/>
<id>40fc9b070ca68e0bd1d57e4dd712172e2faeaa2b</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Array#rassoc should try to convert to array implicitly. Fixes #20003</title>
<updated>2023-11-29T00:39:15+00:00</updated>
<author>
<name>Tema Bolshakov</name>
<email>either.free@gmail.com</email>
</author>
<published>2023-11-12T20:12:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e4a11a1283da07fd1d94535298c605caf299a834'/>
<id>e4a11a1283da07fd1d94535298c605caf299a834</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix compaction during ary_make_partial</title>
<updated>2023-11-27T17:40:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-11-27T16:30:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=150ed44d87e2d5b00f38019a487e05a67a303482'/>
<id>150ed44d87e2d5b00f38019a487e05a67a303482</id>
<content type='text'>
The ary_make_shared call may allocate, which can trigger a GC
compaction. This can cause the array to be embedded because it has a
length of 0.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The ary_make_shared call may allocate, which can trigger a GC
compaction. This can cause the array to be embedded because it has a
length of 0.
</pre>
</div>
</content>
</entry>
<entry>
<title>Get rid of flatten_memo_data_type</title>
<updated>2023-11-22T16:10:03+00:00</updated>
<author>
<name>Jean Boussier</name>
<email>byroot@ruby-lang.org</email>
</author>
<published>2023-11-22T15:01:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9691532428766340462f77ab5b601f9979ebd006'/>
<id>9691532428766340462f77ab5b601f9979ebd006</id>
<content type='text'>
We can use an hidden Hash instead, it's simpler, triggers
write barriers, handle compaction, etc.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We can use an hidden Hash instead, it's simpler, triggers
write barriers, handle compaction, etc.
</pre>
</div>
</content>
</entry>
<entry>
<title>Keep write-barrier status after splicing array</title>
<updated>2023-09-04T12:50:27+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-09-01T14:07:32+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4cc56592932d36c202b2366ffe7ad71db2f5ea0b'/>
<id>4cc56592932d36c202b2366ffe7ad71db2f5ea0b</id>
<content type='text'>
We don't need to remove the write-barrier protected status after
splicing an array. We can simply add it to the rememberset for marking
during the next GC.

The benchmark illustrates the performance impact on minor GC:

```
require "benchmark"

arys = 1_000_000.times.map do
  ary = Array.new(50)
  ary.insert(1, 3)
  ary
end

4.times { GC.start }

puts(Benchmark.measure do
  1000.times do
    GC.start(full_mark: false)
  end
end)
```

This branch:

```
  1.309910   0.004342   1.314252 (  1.314580)
```

Master branch:

```
 54.376091   0.219037  54.595128 ( 54.742996)
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
We don't need to remove the write-barrier protected status after
splicing an array. We can simply add it to the rememberset for marking
during the next GC.

The benchmark illustrates the performance impact on minor GC:

```
require "benchmark"

arys = 1_000_000.times.map do
  ary = Array.new(50)
  ary.insert(1, 3)
  ary
end

4.times { GC.start }

puts(Benchmark.measure do
  1000.times do
    GC.start(full_mark: false)
  end
end)
```

This branch:

```
  1.309910   0.004342   1.314252 (  1.314580)
```

Master branch:

```
 54.376091   0.219037  54.595128 ( 54.742996)
```
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Remove typo</title>
<updated>2023-08-29T10:40:52+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-08-29T10:40:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=247fa3ca7666a5873a575ccfdb78c87753c2ad80'/>
<id>247fa3ca7666a5873a575ccfdb78c87753c2ad80</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix Array#bsearch when block returns a non-integer numeric value</title>
<updated>2023-08-29T09:00:44+00:00</updated>
<author>
<name>Kouhei Yanagita</name>
<email>yanagi@shakenbu.org</email>
</author>
<published>2023-08-29T05:49:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a28c5151f567cada0d2f5c0c3ec4df7f97b80784'/>
<id>a28c5151f567cada0d2f5c0c3ec4df7f97b80784</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
