Project

General

Profile

Actions

Bug #1167

closed

Regexp: Stack overflow in regexp matcher

Added by ender672 (Timothy Elliott) over 15 years ago. Updated over 13 years ago.

Status:
Rejected
Assignee:
-
ruby -v:
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]
[ruby-core:22201]

Description

=begin
A 3,000 character string can cause a stack overflow when matched with a relatively simple regular expression.

This script causes the stack overflow:
string = 'b'
string << 'a' * 3000
regexp = Regexp.new '(?:(\A|t)([^c]*)(?=a))'
p string.match(regexp)

Resulting Error (1.8.7):
./ruby bread_ruby_regexp.rb
bread_ruby_regexp.rb:4:in `match': Stack overflow in regexp matcher: /(?:(\A|t)([^c]*)(?=a))/ (RegexpError)
from bread_ruby_regexp.rb:4

This same script was tested with Ruby 1.9 and it worked as expected:
./ruby bread_ruby_regexp.rb
#<MatchData "baa[...]" 1:"" 2:"baa[...]">

This issue is also referenced here:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/92687
=end

Actions #1

Updated by naruse (Yui NARUSE) about 15 years ago

  • Status changed from Open to Rejected

=begin
this is spec.
=end

Actions

Also available in: Atom PDF

Like0
Like0