summaryrefslogtreecommitdiff
path: root/bootstraptest/test_ractor.rb
diff options
context:
space:
mode:
authornagachika <nagachika@ruby-lang.org>2021-10-09 15:36:53 +0900
committernagachika <nagachika@ruby-lang.org>2021-10-09 15:36:53 +0900
commitcfad0583eb18bb4505f28ee5cfab703a6b9987be (patch)
tree5ebee9ff3e8ef7142dff8b1877315ca61aa10b21 /bootstraptest/test_ractor.rb
parent2c947e74a0a11fe6c54253c15224dc80054c62a2 (diff)
merge revision(s) abc0304cb28cb9dcc3476993bc487884c139fd11: [Backport #17507]
Avoid race condition in Regexp#match In certain conditions, Regexp#match could return a MatchData with missing captures. This seems to require at the least, multiple threads calling a method that calls the same block/proc/lambda which calls Regexp#match. The race condition happens because the MatchData is passed from indirectly via the backref, and other threads can modify the backref. Fix the issue by: 1. Not reusing the existing MatchData from the backref, and always allocating a new MatchData. 2. Passing the MatchData directly to the caller using a VALUE*, instead of indirectly through the backref. It's likely that variants of this issue exist for other Regexp methods. Anywhere that MatchData is passed implicitly through the backref is probably vulnerable to this issue. Fixes [Bug #17507] --- re.c | 46 +++++++++++++++++++--------------------------- test/ruby/test_regexp.rb | 21 +++++++++++++++++++++ 2 files changed, 40 insertions(+), 27 deletions(-)
Diffstat (limited to 'bootstraptest/test_ractor.rb')
0 files changed, 0 insertions, 0 deletions