ruby/test
Daniel Colson d292a9b98c [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](dde99215f2/regexec.c (L1153)),
so if `stk_base != stk_alloc` we can be sure we called
[`stack_double`](dde99215f2/regexec.c (L1210))
and it's safe to free. It's also safe to free if we've
[saved](dde99215f2/regexec.c (L1187-L1189))
the stack to `msa->stack_p`, since we do the `stk_base != stk_alloc`
check before saving.

This matches the check we do inside
[`stack_double`](dde99215f2/regexec.c (L1221))
2024-04-25 10:28:18 -04:00
..
-ext- Expose rb_str_chilled_p 2024-03-26 12:54:54 +01:00
.excludes
.excludes-prism [PRISM] Enable more passing tests 2024-04-25 08:14:56 -04:00
benchmark
cgi
coverage
date [ruby/date] Remove the unintentional ability to parse `Symbol` 2024-02-21 16:04:52 +00:00
did_you_mean Do not include a backtick in error messages and backtraces 2024-02-15 18:42:31 +09:00
digest
dtrace
erb
error_highlight Do not include a backtick in error messages and backtraces 2024-02-15 18:42:31 +09:00
etc
fiber Enumerator should use a non-blocking fiber, change `rb_fiber_new` to be non-blocking by default. (#10481) 2024-04-08 00:49:01 +12:00
fiddle suppress a warning 2023-12-25 22:15:25 +09:00
fileutils
io [ruby/io-console] Load the built extension library in noctty tests 2024-04-10 09:10:50 +00:00
irb [ruby/irb] Memoize helper method instances with Singleton module 2024-04-24 18:32:55 +00:00
json [flori/json] Make OpenStruct support as optional 2024-01-31 14:56:00 +09:00
lib
logger
mkmf [Feature #20345] Add `--target-rbconfig` option to mkmf 2024-04-02 14:24:54 +09:00
monitor ensure to restart antoher thread 2023-12-23 05:56:02 +09:00
net [ruby/net-http] Skip test_session_reuse_but_expire with OpenSSL 3.3 2024-04-25 08:01:53 +00:00
objspace Ensure test suite is compatible with --frozen-string-literal 2024-03-14 17:56:15 +01:00
open-uri
openssl Use www.rfc-editor.org for RFC text. 2024-03-28 11:44:45 +09:00
optparse [ruby/optparse] Invoke pager for `--help` 2024-03-01 07:10:08 +00:00
ostruct
pathname
prism [ruby/prism] Warn for nested hashes as well 2024-04-24 19:39:42 +00:00
psych [ruby/psych] Add :stringify_names option to convert symbol keys to string for dumping 2024-01-18 17:32:34 +00:00
rdoc [ruby/rdoc] test: Add tests for RDoc::TokenStream#add_tokens, add_token ,collect_tokens and pop_token 2024-03-15 00:10:14 +00:00
reline [ruby/reline] Long line performance 2024-04-24 17:33:40 +00:00
resolv [ruby/resolv] Add an explicit with_udp_and_tcp helper to test_dns.rb 2024-03-31 23:57:00 +00:00
ripper Emit `warn` event for duplicated hash keys on ripper 2024-04-15 06:29:25 +09:00
ruby [Bug #20453] segfault in Regexp timeout 2024-04-25 10:28:18 -04:00
rubygems [rubygems/rubygems] Bump rb-sys 2024-04-22 19:15:53 +00:00
set
socket Revise 9ec342e07d 2024-02-26 13:12:05 +09:00
stringio [ruby/stringio] strio_read: preserve buffer encoding on partial 2024-04-17 01:29:18 +00:00
strscan [ruby/strscan] Omit tests for `#scan_byte` and `#peek_byte` on 2024-03-27 12:17:01 +09:00
uri [ruby/uri] Make URI#to_s prepend relative path with / if there is a host or port 2024-01-05 16:07:55 +00:00
win32ole [ruby/win32ole] Test constants for the backward compatibility 2024-03-23 10:34:35 +00:00
yaml [ruby/yaml] Make PStore support as optional 2024-01-31 05:56:39 +00:00
zlib [ruby/zlib] Clear temporary directory 2024-04-20 10:53:41 +00:00
runner.rb
test_delegate.rb
test_extlibs.rb Extract syslog 2024-01-22 15:59:40 +09:00
test_find.rb
test_forwardable.rb [ruby/forwardable] Relax regexp for Ruby 3.3 or before 2024-02-16 02:12:08 +00:00
test_ipaddr.rb [ruby/ipaddr] Add IPAddr.cidr to return ip address in cidr notation 2024-04-18 10:27:19 +09:00
test_open3.rb
test_pp.rb [ruby/pp] Extract pp_hash_pair 2024-02-21 16:45:01 +00:00
test_prettyprint.rb
test_pstore.rb
test_pty.rb
test_rbconfig.rb
test_securerandom.rb
test_shellwords.rb
test_singleton.rb
test_tempfile.rb
test_time.rb
test_timeout.rb
test_tmpdir.rb
test_trick.rb Ensure test suite is compatible with --frozen-string-literal 2024-03-14 17:56:15 +01:00
test_tsort.rb
test_unicode_normalize.rb
test_weakref.rb