<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/regexec.c, 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>Correct castings to use OnigDistance</title>
<updated>2025-07-31T17:02:40+00:00</updated>
<author>
<name>TSUYUSATO Kitsune</name>
<email>make.just.on@gmail.com</email>
</author>
<published>2025-07-28T15:44:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=07f7832cffea879946a796e066ccb13ccb4b2abd'/>
<id>07f7832cffea879946a796e066ccb13ccb4b2abd</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add castings to prevent warnings</title>
<updated>2025-07-31T17:02:40+00:00</updated>
<author>
<name>TSUYUSATO Kitsune</name>
<email>make.just.on@gmail.com</email>
</author>
<published>2025-07-28T09:45:57+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=e6e547f3e582d585bfa00f330d40473c74086c09'/>
<id>e6e547f3e582d585bfa00f330d40473c74086c09</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Port a Oniguruma patch: Integer overflow in onig_search_gpos()</title>
<updated>2025-07-31T17:02:40+00:00</updated>
<author>
<name>TSUYUSATO Kitsune</name>
<email>make.just.on@gmail.com</email>
</author>
<published>2025-07-28T08:50:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9e024046c5f3917149015b9458ec07b145c5428b'/>
<id>9e024046c5f3917149015b9458ec07b145c5428b</id>
<content type='text'>
https://github.com/kkos/oniguruma/commit/778a43dd56925ed58bbe26e3a7bb8202d72c3f3f

It differs from the Oniguruma patch in that it dosen't use `onigenc_get_prev_char_head()`
because this function's signature has been changed by Oniguruma and the change is not ported
in Onigmo for now. This patch respects the current Onigmo implementation.

Co-Authored-By: K.Kosako &lt;kkos@users.noreply.github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/kkos/oniguruma/commit/778a43dd56925ed58bbe26e3a7bb8202d72c3f3f

It differs from the Oniguruma patch in that it dosen't use `onigenc_get_prev_char_head()`
because this function's signature has been changed by Oniguruma and the change is not ported
in Onigmo for now. This patch respects the current Onigmo implementation.

Co-Authored-By: K.Kosako &lt;kkos@users.noreply.github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Port a Oniguruma patch: Integer overflow in backward_search_range() and onig_search_gpos()</title>
<updated>2025-07-31T17:02:40+00:00</updated>
<author>
<name>TSUYUSATO Kitsune</name>
<email>make.just.on@gmail.com</email>
</author>
<published>2025-07-28T07:18:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=142fc23975e9e240d6b4a5ee4d63c45ab969fd10'/>
<id>142fc23975e9e240d6b4a5ee4d63c45ab969fd10</id>
<content type='text'>
https://github.com/kkos/oniguruma/commit/bfc36d3d8139b8be4d3df630d625c58687b0c7d4

Co-Authored-By: K.Kosako &lt;kkos@users.noreply.github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/kkos/oniguruma/commit/bfc36d3d8139b8be4d3df630d625c58687b0c7d4

Co-Authored-By: K.Kosako &lt;kkos@users.noreply.github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Port a Oniguruma patch: Integer overflow in forward_search_range()</title>
<updated>2025-07-31T17:02:40+00:00</updated>
<author>
<name>TSUYUSATO Kitsune</name>
<email>make.just.on@gmail.com</email>
</author>
<published>2025-07-28T07:05:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9f45db04ac36386aedfb35d1f3a5ff9603a24d68'/>
<id>9f45db04ac36386aedfb35d1f3a5ff9603a24d68</id>
<content type='text'>
https://github.com/kkos/oniguruma/commit/db64ef3189f54917a5008a02bdb000adc514a90a

Co-Authored-By: K.Kosako &lt;kkos@users.noreply.github.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
https://github.com/kkos/oniguruma/commit/db64ef3189f54917a5008a02bdb000adc514a90a

Co-Authored-By: K.Kosako &lt;kkos@users.noreply.github.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix regex timeout double-free after stack_double</title>
<updated>2024-11-12T07:33:21+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2024-11-05T02:05:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8409edc4971f34cf0d77c375909c5b8f7b1e058a'/>
<id>8409edc4971f34cf0d77c375909c5b8f7b1e058a</id>
<content type='text'>
As of 10574857ce167869524b97ee862b610928f6272f, it's possible to crash
on a double free due to `stk_alloc` AKA `msa-&gt;stack_p` being freed
twice, once at the end of match_at and a second time in `FREE_MATCH_ARG`
in the parent caller.

Fixes [Bug #20886]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As of 10574857ce167869524b97ee862b610928f6272f, it's possible to crash
on a double free due to `stk_alloc` AKA `msa-&gt;stack_p` being freed
twice, once at the end of match_at and a second time in `FREE_MATCH_ARG`
in the parent caller.

Fixes [Bug #20886]
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Fix typos</title>
<updated>2024-10-31T03:44:50+00:00</updated>
<author>
<name>kojix2</name>
<email>2xijok@gmail.com</email>
</author>
<published>2024-10-31T03:44:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=550ac2f2edc07d1b63e3755233df0758a652b53f'/>
<id>550ac2f2edc07d1b63e3755233df0758a652b53f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix size modifier for `size_t`</title>
<updated>2024-09-25T01:40:14+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2024-09-25T01:40:14+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=c94ea1cccb24a41a5cd5c7e90aec04cb477b367e'/>
<id>c94ea1cccb24a41a5cd5c7e90aec04cb477b367e</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix memory leak in String#start_with? when regexp times out</title>
<updated>2024-07-26T12:42:38+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-07-25T19:28:25+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7464514ca5e825ada31522b63a33e02d62a0a248'/>
<id>7464514ca5e825ada31522b63a33e02d62a0a248</id>
<content type='text'>
[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>
[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>Fix memory leak in Regexp capture group when timeout</title>
<updated>2024-07-25T13:23:49+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-07-24T19:16:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=10574857ce167869524b97ee862b610928f6272f'/>
<id>10574857ce167869524b97ee862b610928f6272f</id>
<content type='text'>
[Bug #20650]

The capture group allocates memory that is leaked when it times out.

For example:

    re = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001)
    str = "a" * 1000000 + "x"

    10.times do
      100.times do
        re =~ str
      rescue Regexp::TimeoutError
      end

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

Before:

    34688
    56416
    78288
    100368
    120784
    140704
    161904
    183568
    204320
    224800

After:

    16288
    16288
    16880
    16896
    16912
    16928
    16944
    17184
    17184
    17200
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #20650]

The capture group allocates memory that is leaked when it times out.

For example:

    re = Regexp.new("^#{"(a*)" * 10_000}x$", timeout: 0.000001)
    str = "a" * 1000000 + "x"

    10.times do
      100.times do
        re =~ str
      rescue Regexp::TimeoutError
      end

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

Before:

    34688
    56416
    78288
    100368
    120784
    140704
    161904
    183568
    204320
    224800

After:

    16288
    16288
    16880
    16896
    16912
    16928
    16944
    17184
    17184
    17200
</pre>
</div>
</content>
</entry>
</feed>
