Bug #1167: Regexp: Stack overflow in regexp matcher http://redmine.ruby-lang.org/issues/show/1167 Author: Timothy Elliott Status: Open, Priority: Normal ruby -v: ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux] 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 ---------------------------------------- http://redmine.ruby-lang.org