<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_string.rb, 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) fa85d23ff4a02985ebfe0716b0ff768f5b4fe13d: [Backport #21380]</title>
<updated>2025-06-15T03:51:29+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2025-06-15T03:51:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8908cb07829628115f7455508c2d5885ac99c939'/>
<id>8908cb07829628115f7455508c2d5885ac99c939</id>
<content type='text'>
	[Bug #21380] Prohibit modification in String#split block

	Reported at https://hackerone.com/reports/3163876
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #21380] Prohibit modification in String#split block

	Reported at https://hackerone.com/reports/3163876
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 02b70256b5171d4b85ea7eeab836d3d7cfb3dbfc, 6b4f8945d600168bf530d21395da8293fbd5e8ba: [Backport #20909]</title>
<updated>2025-01-15T01:50:24+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2025-01-15T01:50:24+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1e48631e0f318a3b73cd39bdbda4619017383aac'/>
<id>1e48631e0f318a3b73cd39bdbda4619017383aac</id>
<content type='text'>
	Check negative integer underflow

	Many of Oniguruma functions need valid encoding strings
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Check negative integer underflow

	Many of Oniguruma functions need valid encoding strings
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #20653] Fix memory leak in String#start_with? when regexp times out (#11255)</title>
<updated>2024-07-30T00:45:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-07-30T00:45:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ce565cd4b851977bf37a470bee54e441bb60486d'/>
<id>ce565cd4b851977bf37a470bee54e441bb60486d</id>
<content type='text'>
Fix memory leak in String#start_with? when regexp times out

[Bug #20653]

This commit refactors how Onigmo handles timeout. Instead of raising a
timeout error, onig_search will return a ONIGERR_TIMEOUT which the
caller can free memory, and then raise a timeout error.

This fixes a memory leak in String#start_with when the regexp times out.
For example:

    regex = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001)
    str = "a" * 1000000 + "x"

    10.times do
      100.times do
        str.start_with?(regex)
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    33216
    51936
    71152
    81728
    97152
    103248
    120384
    133392
    133520
    133616

After:

    14912
    15376
    15824
    15824
    16128
    16128
    16144
    16144
    16160
    16160</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix memory leak in String#start_with? when regexp times out

[Bug #20653]

This commit refactors how Onigmo handles timeout. Instead of raising a
timeout error, onig_search will return a ONIGERR_TIMEOUT which the
caller can free memory, and then raise a timeout error.

This fixes a memory leak in String#start_with when the regexp times out.
For example:

    regex = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001)
    str = "a" * 1000000 + "x"

    10.times do
      100.times do
        str.start_with?(regex)
      rescue
      end

      puts `ps -o rss= -p #{$$}`
    end

Before:

    33216
    51936
    71152
    81728
    97152
    103248
    120384
    133392
    133520
    133616

After:

    14912
    15376
    15824
    15824
    16128
    16128
    16144
    16144
    16160
    16160</pre>
</div>
</content>
</entry>
<entry>
<title>Skip under_gc_compact_stress on s390x (#10073)</title>
<updated>2024-05-29T18:13:02+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2024-02-22T22:34:19+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=2f4fe76eff0a8c6ab7a1d2fb845453acfc3cb206'/>
<id>2f4fe76eff0a8c6ab7a1d2fb845453acfc3cb206</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) e04146129ec6898dd6a9739dad2983c6e9b68056: [Backport #20292]</title>
<updated>2024-05-29T17:19:49+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2024-05-29T17:19:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f12c947192aa47b355015384e5c82cbf674023f1'/>
<id>f12c947192aa47b355015384e5c82cbf674023f1</id>
<content type='text'>
	[Bug #20292] Truncate embedded string to new capacity
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #20292] Truncate embedded string to new capacity
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) ade56737e2273847426214035c0ff2340b43799a: [Backport #20190] (#10300)</title>
<updated>2024-03-20T13:40:46+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-20T13:40:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ce372be903e5f3597f1dc83cb558f165850b3bee'/>
<id>ce372be903e5f3597f1dc83cb558f165850b3bee</id>
<content type='text'>
Fix coderange of invalid_encoding_string.&lt;&lt;(ord)

	Appending valid encoding character can change coderange from invalid to valid.
	Example: "\x95".force_encoding('sjis')&lt;&lt;0x5C will be a valid string "\x{955C}"</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix coderange of invalid_encoding_string.&lt;&lt;(ord)

	Appending valid encoding character can change coderange from invalid to valid.
	Example: "\x95".force_encoding('sjis')&lt;&lt;0x5C will be a valid string "\x{955C}"</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) b3d612804946e841e47d14e09b6839224a79c1a4: [Backport #20150] (#10253)</title>
<updated>2024-03-14T14:18:15+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-14T14:18:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fafe5db7328eb3395ac4559992701b5f25ab49f4'/>
<id>fafe5db7328eb3395ac4559992701b5f25ab49f4</id>
<content type='text'>
Fix memory leak in grapheme clusters

	[Bug #20150]

	String#grapheme_cluters and String#each_grapheme_cluster leaks memory
	because if the string is not UTF-8, then the created regex will not
	be freed.

	For example:

	    str = "hello world".encode(Encoding::UTF_32LE)

	    10.times do
	      1_000.times do
	        str.grapheme_clusters
	      end

	      puts `ps -o rss= -p #{$$}`
	    end

	Before:

	    26000
	    42256
	    59008
	    75792
	    92528
	    109232
	    125936
	    142672
	    159392
	    176160

	After:

	    9264
	    9504
	    9808
	    10000
	    10128
	    10224
	    10352
	    10544
	    10704
	    10896
	---
	 string.c                 | 98 +++++++++++++++++++++++++++++++-----------------
	 test/ruby/test_string.rb | 11 ++++++
	 2 files changed, 75 insertions(+), 34 deletions(-)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix memory leak in grapheme clusters

	[Bug #20150]

	String#grapheme_cluters and String#each_grapheme_cluster leaks memory
	because if the string is not UTF-8, then the created regex will not
	be freed.

	For example:

	    str = "hello world".encode(Encoding::UTF_32LE)

	    10.times do
	      1_000.times do
	        str.grapheme_clusters
	      end

	      puts `ps -o rss= -p #{$$}`
	    end

	Before:

	    26000
	    42256
	    59008
	    75792
	    92528
	    109232
	    125936
	    142672
	    159392
	    176160

	After:

	    9264
	    9504
	    9808
	    10000
	    10128
	    10224
	    10352
	    10544
	    10704
	    10896
	---
	 string.c                 | 98 +++++++++++++++++++++++++++++++-----------------
	 test/ruby/test_string.rb | 11 ++++++
	 2 files changed, 75 insertions(+), 34 deletions(-)</pre>
</div>
</content>
</entry>
<entry>
<title>Fix String#sub for GC compaction</title>
<updated>2023-12-23T23:00:27+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-12-23T21:22:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=50bf4373411a8780270c7ba1cc983d5756a4fde1'/>
<id>50bf4373411a8780270c7ba1cc983d5756a4fde1</id>
<content type='text'>
The test fails when RGENGC_CHECK_MODE is turned on:

    TestString#test_sub_gc_compact_stress = 9.42 s
    1) Failure:
    TestString#test_sub_gc_compact_stress [test/ruby/test_string.rb:2089]:
    &lt;"aaa [amp] yyy"&gt; expected but was
    &lt;"aaa [] yyy"&gt;.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The test fails when RGENGC_CHECK_MODE is turned on:

    TestString#test_sub_gc_compact_stress = 9.42 s
    1) Failure:
    TestString#test_sub_gc_compact_stress [test/ruby/test_string.rb:2089]:
    &lt;"aaa [amp] yyy"&gt; expected but was
    &lt;"aaa [] yyy"&gt;.
</pre>
</div>
</content>
</entry>
<entry>
<title>Stir the hash value more with encoding index</title>
<updated>2023-12-16T15:30:00+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-12-16T15:30:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=ab7f54688b495b3218843e58992b713c3b28011f'/>
<id>ab7f54688b495b3218843e58992b713c3b28011f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #20068] Encoding does not matter to empty strings</title>
<updated>2023-12-16T07:00:12+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-12-16T04:48:49+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b710f96b5aaeb6c153e4b1a7e1b46c4521214126'/>
<id>b710f96b5aaeb6c153e4b1a7e1b46c4521214126</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
