<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/re.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>[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>merge revision(s) 01bfd1a2bf013a9ed92a9722ac5228187e05e6a8,1c120efe02d079b0a1dea573cf0fd7978d9cc857,31378dc0969f4466b2122d730b7298dd7004acdf: [Backport #20228] (#10301)</title>
<updated>2024-03-20T13:40:50+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-20T13:40:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c626c201e4129bbea17583ecef73472c6f668c81'/>
<id>c626c201e4129bbea17583ecef73472c6f668c81</id>
<content type='text'>
Fix memory leak in OnigRegion when match raises

	[Bug #20228]

	rb_reg_onig_match can raise a Regexp::TimeoutError, which would cause
	the OnigRegion to leak.

	Fix memory leak in stk_base when Regexp timeout

	[Bug #20228]

	If rb_reg_check_timeout raises a Regexp::TimeoutError, then the stk_base
	will leak.

	Add memory leak test for Regexp timeout

	[Bug #20228]</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fix memory leak in OnigRegion when match raises

	[Bug #20228]

	rb_reg_onig_match can raise a Regexp::TimeoutError, which would cause
	the OnigRegion to leak.

	Fix memory leak in stk_base when Regexp timeout

	[Bug #20228]

	If rb_reg_check_timeout raises a Regexp::TimeoutError, then the stk_base
	will leak.

	Add memory leak test for Regexp timeout

	[Bug #20228]</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) e12d4c654e3cb7a4473014610bc3bae41aaf811e: [Backport #20104]</title>
<updated>2024-01-30T11:29:02+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2024-01-30T11:29:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f585171a6b1d6c20b3c162fd59dc874510ed2a49'/>
<id>f585171a6b1d6c20b3c162fd59dc874510ed2a49</id>
<content type='text'>
	Don't create T_MATCH object if /regexp/.match(string) doesn't match

	Fixes [Bug #20104]
	---
	 re.c                     |  9 ++++++---
	 test/ruby/test_regexp.rb | 12 ++++++++++++
	 tool/lib/envutil.rb      |  8 ++++++++
	 3 files changed, 26 insertions(+), 3 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	Don't create T_MATCH object if /regexp/.match(string) doesn't match

	Fixes [Bug #20104]
	---
	 re.c                     |  9 ++++++---
	 test/ruby/test_regexp.rb | 12 ++++++++++++
	 tool/lib/envutil.rb      |  8 ++++++++
	 3 files changed, 26 insertions(+), 3 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix Regexp#inspect for GC compaction</title>
<updated>2023-12-24T16:04:41+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-12-24T14:08:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f0efeddd41f96d3afae9af73a3dc594d86614f4b'/>
<id>f0efeddd41f96d3afae9af73a3dc594d86614f4b</id>
<content type='text'>
rb_reg_desc was not safe for GC compaction because it took in the C
string and length but not the backing String object so it get moved
during compaction. This commit changes rb_reg_desc to use the string
from the Regexp object.

The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_inspect_under_gc_compact_stress [test/ruby/test_regexp.rb:474]:
    &lt;"(?-mix:\\/)|"&gt; expected but was
    &lt;"/\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00/"&gt;.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
rb_reg_desc was not safe for GC compaction because it took in the C
string and length but not the backing String object so it get moved
during compaction. This commit changes rb_reg_desc to use the string
from the Regexp object.

The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_inspect_under_gc_compact_stress [test/ruby/test_regexp.rb:474]:
    &lt;"(?-mix:\\/)|"&gt; expected but was
    &lt;"/\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00/"&gt;.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix Regexp#match for GC compaction</title>
<updated>2023-12-24T14:03:55+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-12-24T01:24:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=42442ed7891b1c721b4a306f21ce9548a69e7be3'/>
<id>42442ed7891b1c721b4a306f21ce9548a69e7be3</id>
<content type='text'>
The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_match_under_gc_compact_stress:
    NoMethodError: undefined method `match' for nil
        test_regexp.rb:878:in `block in test_match_under_gc_compact_stress'
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_match_under_gc_compact_stress:
    NoMethodError: undefined method `match' for nil
        test_regexp.rb:878:in `block in test_match_under_gc_compact_stress'
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix Regexp#to_s for GC compaction</title>
<updated>2023-12-23T21:52:05+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2023-12-23T19:51:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fadda88903d9fe764ae53eca07aaf85f08e162a7'/>
<id>fadda88903d9fe764ae53eca07aaf85f08e162a7</id>
<content type='text'>
The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_to_s_under_gc_compact_stress = 13.46 s
    1) Failure:
    TestRegexp#test_to_s_under_gc_compact_stress [test/ruby/test_regexp.rb:81]:
    &lt;"(?-mix:abcd\u3042)"&gt; expected but was
    &lt;"(?-mix:\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030)"&gt;.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The test fails when RGENGC_CHECK_MODE is turned on:

    TestRegexp#test_to_s_under_gc_compact_stress = 13.46 s
    1) Failure:
    TestRegexp#test_to_s_under_gc_compact_stress [test/ruby/test_regexp.rb:81]:
    &lt;"(?-mix:abcd\u3042)"&gt; expected but was
    &lt;"(?-mix:\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030\u5C78\u3030)"&gt;.
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] State MatchData#[] when multiple captures with the same name</title>
<updated>2023-12-19T04:48:51+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-12-19T03:59:43+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=dee45ac231afd02797640cb335d86550aa620cbe'/>
<id>dee45ac231afd02797640cb335d86550aa620cbe</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Adjust some new features wording/examples. (#9183)</title>
<updated>2023-12-14T21:01:48+00:00</updated>
<author>
<name>Victor Shepelev</name>
<email>zverok.offline@gmail.com</email>
</author>
<published>2023-12-14T21:01:48+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=570d7b2c3e2ee39e07548dfe242b684ec794789d'/>
<id>570d7b2c3e2ee39e07548dfe242b684ec794789d</id>
<content type='text'>
* Reword Range#overlap? docs last paragraph.

* Docs: add explanation about Queue#freeze

* Docs: Add :rescue event docs for TracePoint

* Docs: Enhance Module#set_temporary_name documentation

* Docs: Slightly expand Process::Status deprecations

* Fix MatchData#named_captures rendering glitch

* Improve Dir.fchdir examples

* Adjust Refinement#target docs</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* Reword Range#overlap? docs last paragraph.

* Docs: add explanation about Queue#freeze

* Docs: Add :rescue event docs for TracePoint

* Docs: Enhance Module#set_temporary_name documentation

* Docs: Slightly expand Process::Status deprecations

* Fix MatchData#named_captures rendering glitch

* Improve Dir.fchdir examples

* Adjust Refinement#target docs</pre>
</div>
</content>
</entry>
<entry>
<title>Copy encoding flags when copying a regex [Bug #20039]</title>
<updated>2023-12-07T03:25:29+00:00</updated>
<author>
<name>Dustin Brown</name>
<email>dbrown9@gmail.com</email>
</author>
<published>2023-12-07T03:25:29+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=d89280e8bf6496aa83326b5f9c293724bd1cc1e9'/>
<id>d89280e8bf6496aa83326b5f9c293724bd1cc1e9</id>
<content type='text'>
* :bug: Fixes [Bug #20039](https://bugs.ruby-lang.org/issues/20039)

When a Regexp is initialized with another Regexp, we simply copy the
properties from the original. However, the flags on the original were
not being copied correctly. This caused an issue when the original had
multibyte characters and was being compared with an ASCII string.
Without the forced encoding flag (`KCODE_FIXED`) transferred on to the
new Regexp, the comparison would fail. See the included test for an
example.

Co-authored-by: Nobuyoshi Nakada &lt;nobu@ruby-lang.org&gt;</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
* :bug: Fixes [Bug #20039](https://bugs.ruby-lang.org/issues/20039)

When a Regexp is initialized with another Regexp, we simply copy the
properties from the original. However, the flags on the original were
not being copied correctly. This caused an issue when the original had
multibyte characters and was being compared with an ASCII string.
Without the forced encoding flag (`KCODE_FIXED`) transferred on to the
new Regexp, the comparison would fail. See the included test for an
example.

Co-authored-by: Nobuyoshi Nakada &lt;nobu@ruby-lang.org&gt;</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Fix doc/regexp.rdoc links</title>
<updated>2023-11-14T06:56:57+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-11-14T04:53:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=caa9881fde884238e38c2decea97ecfca559280c'/>
<id>caa9881fde884238e38c2decea97ecfca559280c</id>
<content type='text'>
- Rename regexp.rdoc to exclude from "Pages".  This file is for to be
  included in the "class Regexp" document, but it also appeared as a
  separate page duplicately.
- Fix links on case-sensitive filesystems.
- Fix to use rdoc-ref instead of converted HTML page names.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
- Rename regexp.rdoc to exclude from "Pages".  This file is for to be
  included in the "class Regexp" document, but it also appeared as a
  separate page duplicately.
- Fix links on case-sensitive filesystems.
- Fix to use rdoc-ref instead of converted HTML page names.
</pre>
</div>
</content>
</entry>
</feed>
