Actions
Bug #1167
closedRegexp: Stack overflow in regexp matcher
Status:
Rejected
Assignee:
-
ruby -v:
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]
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
Updated by naruse (Yui NARUSE) about 15 years ago
- Status changed from Open to Rejected
=begin
this is spec.
=end
Actions
Like0
Like0