<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_regexp.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>Fix initialization of the table for quick search</title>
<updated>2025-11-02T05:12:22+00:00</updated>
<author>
<name>K.Takata</name>
<email>kentkt@csc.jp</email>
</author>
<published>2019-01-28T09:52:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cd116d2ac5369b9d0f5ae4421c2994556ebbf0ad'/>
<id>cd116d2ac5369b9d0f5ae4421c2994556ebbf0ad</id>
<content type='text'>
This fixes k-takata/Onigmo#120.

The commit k-takata/Onigmo@9c13de8d0684ebde97e3709d7693997c81ca374b was insufficient.

https://github.com/k-takata/Onigmo/commit/1de602ddff140d91419e3f86dd35c81d7bd2d8e7
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This fixes k-takata/Onigmo#120.

The commit k-takata/Onigmo@9c13de8d0684ebde97e3709d7693997c81ca374b was insufficient.

https://github.com/k-takata/Onigmo/commit/1de602ddff140d91419e3f86dd35c81d7bd2d8e7
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #13671] Fix that "ss" in look-behind causes syntax error</title>
<updated>2025-11-02T05:11:36+00:00</updated>
<author>
<name>K.Takata</name>
<email>kentkt@csc.jp</email>
</author>
<published>2019-01-25T09:54:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f0feca1a8495eba2706a7914f0c4f8128c281366'/>
<id>f0feca1a8495eba2706a7914f0c4f8128c281366</id>
<content type='text'>
Fixes k-takata/Onigmo#92.

This fix was ported from oniguruma:
https://github.com/kkos/oniguruma/commit/257082dac8c6019198b56324012f0bd1830ff4ba

https://github.com/k-takata/Onigmo/commit/b1a5445fbeba97b3e94a733c2ce11c033453af73
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Fixes k-takata/Onigmo#92.

This fix was ported from oniguruma:
https://github.com/kkos/oniguruma/commit/257082dac8c6019198b56324012f0bd1830ff4ba

https://github.com/k-takata/Onigmo/commit/b1a5445fbeba97b3e94a733c2ce11c033453af73
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #20886] Avoid double-free in regex timeout after stack_double (#12063)</title>
<updated>2024-11-12T17:04:21+00:00</updated>
<author>
<name>John Hawthorn</name>
<email>john@hawthorn.email</email>
</author>
<published>2024-11-12T17:04:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f4258aaed02ee7be761f2499b0b6243a8f37b7cb'/>
<id>f4258aaed02ee7be761f2499b0b6243a8f37b7cb</id>
<content type='text'>
Fix regex timeout double-free after stack_double

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>
Fix regex timeout double-free after stack_double

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>[Bug #20650] Fix memory leak in Regexp capture group when timeout (#11244)</title>
<updated>2024-07-25T16:14:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-07-25T16:14:26+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7571ad42f42939d172ec9a68dfe56aac724ee2ef'/>
<id>7571ad42f42939d172ec9a68dfe56aac724ee2ef</id>
<content type='text'>
Fix memory leak in Regexp capture group when timeout

[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>
Fix memory leak in Regexp capture group when timeout

[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>
<entry>
<title>merge revision(s) d292a9b98ce03c76dbe13138d20b9fbf613cc02d: [Backport #20453]</title>
<updated>2024-05-29T22:52:15+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2024-05-29T22:52:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=cf643fabd5c564c1dfeb337b50b4aa76ebaa11c1'/>
<id>cf643fabd5c564c1dfeb337b50b4aa76ebaa11c1</id>
<content type='text'>
	[Bug #20453] segfault in Regexp timeout

	https://bugs.ruby-lang.org/issues/20228 started freeing `stk_base` to
	avoid a memory leak. But `stk_base` is sometimes stack allocated (using
	`xalloca`), so the free only works if the regex stack has grown enough
	to hit `stack_double` (which uses `xmalloc` and `xrealloc`).

	To reproduce the problem on master and 3.3.1:

	```ruby
	Regexp.timeout = 0.001
	/^(a*)x$/ =~ "a" * 1000000 + "x"'
	```

	Some details about this potential fix:

	`stk_base == stk_alloc` on
	[init](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1153),
	so if `stk_base != stk_alloc` we can be sure we called
	[`stack_double`](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1210)
	and it's safe to free. It's also safe to free if we've
	[saved](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1187-L1189)
	the stack to `msa-&gt;stack_p`, since we do the `stk_base != stk_alloc`
	check before saving.

	This matches the check we do inside
	[`stack_double`](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1221)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #20453] segfault in Regexp timeout

	https://bugs.ruby-lang.org/issues/20228 started freeing `stk_base` to
	avoid a memory leak. But `stk_base` is sometimes stack allocated (using
	`xalloca`), so the free only works if the regex stack has grown enough
	to hit `stack_double` (which uses `xmalloc` and `xrealloc`).

	To reproduce the problem on master and 3.3.1:

	```ruby
	Regexp.timeout = 0.001
	/^(a*)x$/ =~ "a" * 1000000 + "x"'
	```

	Some details about this potential fix:

	`stk_base == stk_alloc` on
	[init](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1153),
	so if `stk_base != stk_alloc` we can be sure we called
	[`stack_double`](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1210)
	and it's safe to free. It's also safe to free if we've
	[saved](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1187-L1189)
	the stack to `msa-&gt;stack_p`, since we do the `stk_base != stk_alloc`
	check before saving.

	This matches the check we do inside
	[`stack_double`](https://github.com/ruby/ruby/blob/dde99215f2bc60c22a00fc941ff7f714f011e920/regexec.c#L1221)
</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>Fix RegExp warning causing flaky Ripper failure</title>
<updated>2024-05-28T22:05:52+00:00</updated>
<author>
<name>Alan Wu</name>
<email>XrXr@users.noreply.github.com</email>
</author>
<published>2024-01-29T21:37:37+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4024feba55ccf7525e4e1e0fdbca9eda5dac3b86'/>
<id>4024feba55ccf7525e4e1e0fdbca9eda5dac3b86</id>
<content type='text'>
Sometimes this file get picked up and break Ripper tests:

    TestRipper::Generic#test_parse_files:test/ruby
    assert_separately failed with error message
    pid 63392 exit 0
    | test_regexp.rb:2025: warning: character class has duplicated range

https://github.com/ruby/ruby/actions/runs/7699956651/job/20982702553#step:12:103
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Sometimes this file get picked up and break Ripper tests:

    TestRipper::Generic#test_parse_files:test/ruby
    assert_separately failed with error message
    pid 63392 exit 0
    | test_regexp.rb:2025: warning: character class has duplicated range

https://github.com/ruby/ruby/actions/runs/7699956651/job/20982702553#step:12:103
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 18ee7c9a108bf3424814565377c8796e5e455cf7,4a6384ed9358e8fb8464f6e37efb5477182f01db: [Backport #20246] (#10309)</title>
<updated>2024-03-21T00:10:44+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-21T00:10:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=05787897f69087abdabee926971cdf364bd73730'/>
<id>05787897f69087abdabee926971cdf364bd73730</id>
<content type='text'>
Clear all refined CCs on reopening refinement mod

	In cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 we started using inline
	caches for refinements. However, we weren't clearing inline caches when
	defined on a reopened refinement module.

	Fixes [Bug #20246]

	Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Clear all refined CCs on reopening refinement mod

	In cfd7729ce7a31c8b6ec5dd0e99c67b2932de4732 we started using inline
	caches for refinements. However, we weren't clearing inline caches when
	defined on a reopened refinement module.

	Fixes [Bug #20246]

	Fix [Bug #20246]: Don't set next_head_exact if a capture is called (#9897)</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) 3e6e3ca2627b1aa71b17de902cc1b8188246a828: [Backport #20207] (#10299)</title>
<updated>2024-03-20T17:13:59+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>nurse@users.noreply.github.com</email>
</author>
<published>2024-03-20T17:13:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=00cb72157a60c20a9b9d9fe81fc974ea83d672b4'/>
<id>00cb72157a60c20a9b9d9fe81fc974ea83d672b4</id>
<content type='text'>
Correctly handle consecutive lookarounds (#9738)

	Fix [Bug #20207]
	Fix [Bug #20212]

	Handling consecutive lookarounds in init_cache_opcodes is buggy, so it
	causes invalid memory access reported in [Bug #20207] and [Bug #20212].
	This fixes it by using recursive functions to detected lookarounds
	nesting correctly.</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Correctly handle consecutive lookarounds (#9738)

	Fix [Bug #20207]
	Fix [Bug #20212]

	Handling consecutive lookarounds in init_cache_opcodes is buggy, so it
	causes invalid memory access reported in [Bug #20207] and [Bug #20212].
	This fixes it by using recursive functions to detected lookarounds
	nesting correctly.</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>
</feed>
