Defect #11941
closedRexexpError when parsing commit log with many #nnnn and ruby1.8
0%
Description
We have a large commit log that has a bunch of strings in the format of #nnnn (208 in total). Redmine changeset fetch processing is failing with a stack overflow in the regular expression scan of the commit log.
Attached is a file that contains the string from the commit log that will reproduce the error. Reusing the regular expression that is created in changesets.rb the following code snippet will reproduce the problem
s = IO.readlines("bad").join() s.scan(/([\s\(\[,-]|^)((refs|references|issueid|issueid|defectid|defectid|fixes|closes|resolves|fixes|closes|resolves)[\s:]+)?(#\d+(\s+@(?x-mi:(((\d+)(h|hours?))((\d+)(m|min)?)?|((\d+)(h|hours?|m|min))|(\d+):(\d+)|(\d+([\.,]\d+)?)h?)))?([\s,;&]+#\d+(\s+@(?x-mi:(((\d+)(h|hours?))((\d+)(m|min)?)?|((\d+)(h|hours?|m|min))|(\d+):(\d+)|(\d+([\.,]\d+)?)h?)))?)*)(?=[[:punct:]]|\s|<|$)/i) RegexpError: Stack overflow in regexp matcher:...
Info about our environment
RAILS_ENV=production ruby script/about About your application's environment Ruby version 1.8.7 (x86_64-linux) RubyGems version 1.3.7 Rack version 1.1.3 Rails version 2.3.14 Active Record version 2.3.14 Active Resource version 2.3.14 Action Mailer version 2.3.14 Active Support version 2.3.14 Application root /var/lib/redmine Environment production Database adapter mysql Database schema version 20110902000000 About your Redmine plugins Mylyn Connector plugin 2.7.4.stable Project Subscription 0.0.1b Redmine ChangeAuthor plugin 0.0.2 Redmine Vendor Display plugin 1.0 Redmine Groups plugin 1.0.0 Redmine Better Gantt Chart plugin 0.6.1
Backtrace
Sep 24 15:38:38 penguin1 Redmine[21183]: RegexpError (Stack overflow in regexp matcher: /([\s\(\[,-]|^)((refs|references|issueid|issueid|defectid|defectid|fixes|closes|resolves|fixes|closes|resolves)[\s:]+)?(#\d+(\s+@(?x-mi: Sep 24 15:38:38 penguin1 ( Sep 24 15:38:38 penguin1 ((\d+)(h|hours?))((\d+)(m|min)?)? Sep 24 15:38:38 penguin1 | Sep 24 15:38:38 penguin1 ((\d+)(h|hours?|m|min)) Sep 24 15:38:38 penguin1 | Sep 24 15:38:38 penguin1 (\d+):(\d+) Sep 24 15:38:38 penguin1 | Sep 24 15:38:38 penguin1 (\d+([\.,]\d+)?)h? Sep 24 15:38:38 penguin1 ) Sep 24 15:38:38 penguin1 ))?([\s,;&]+#\d+(\s+@(?x-mi: Sep 24 15:38:38 penguin1 ( Sep 24 15:38:38 penguin1 ((\d+)(h|hours?))((\d+)(m|min)?)? Sep 24 15:38:38 penguin1 | Sep 24 15:38:38 penguin1 ((\d+)(h|hours?|m|min)) Sep 24 15:38:38 penguin1 | Sep 24 15:38:38 penguin1 (\d+):(\d+) Sep 24 15:38:38 penguin1 | Sep 24 15:38:38 penguin1 (\d+([\.,]\d+)?)h? Sep 24 15:38:38 penguin1 ) Sep 24 15:38:38 penguin1 ))?)*)(?=[[:punct:]]|\s|<|$)/i): Sep 24 15:38:38 penguin1 app/models/changeset.rb:128:in `scan' Sep 24 15:38:38 penguin1 app/models/changeset.rb:128:in `scan_comment_for_issue_ids' Sep 24 15:38:38 penguin1 app/models/changeset.rb:101:in `scan_for_issues' Sep 24 15:38:38 penguin1 app/models/repository/subversion.rb:67:in `fetch_changesets' Sep 24 15:38:38 penguin1 app/models/repository/subversion.rb:66:in `fetch_changesets' Sep 24 15:38:38 penguin1 app/models/repository/subversion.rb:65:in `reverse_each' Sep 24 15:38:38 penguin1 app/models/repository/subversion.rb:65:in `fetch_changesets' Sep 24 15:38:38 penguin1 app/controllers/repositories_controller.rb:92:in `show' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/rack/request_handler.rb:96:in `process_request' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_request_handler.rb:513:in `accept_and_process_next_request' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_request_handler.rb:274:in `main_loop' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/classic_rails/application_spawner.rb:321:in `start_request_handler' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/classic_rails/application_spawner.rb:275:in `send' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/classic_rails/application_spawner.rb:275:in `handle_spawn_application' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/utils.rb:479:in `safe_fork' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/classic_rails/application_spawner.rb:270:in `handle_spawn_application' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server.rb:357:in `__send__' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server.rb:357:in `server_main_loop' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server.rb:206:in `start_synchronously' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server.rb:180:in `start' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/classic_rails/application_spawner.rb:149:in `start' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/spawn_manager.rb:219:in `spawn_rails_application' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server_collection.rb:132:in `lookup_or_add' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/spawn_manager.rb:214:in `spawn_rails_application' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server_collection.rb:82:in `synchronize' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server_collection.rb:79:in `synchronize' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/spawn_manager.rb:213:in `spawn_rails_application' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/spawn_manager.rb:132:in `spawn_application' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/spawn_manager.rb:275:in `handle_spawn_application' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server.rb:357:in `__send__' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server.rb:357:in `server_main_loop' Sep 24 15:38:38 penguin1 /usr/lib64/ruby/site_ruby/1.8/phusion_passenger/abstract_server.rb:206:in `start_synchronously' Sep 24 15:38:38 penguin1 /usr/share/phusion-passenger/helper-scripts/passenger-spawn-server:99 Sep 24 15:38:38 penguin1 Redmine[21183]: Rendering /var/lib/redmine/public/500.html (500 Internal Server Error)
Files
Updated by Jean-Philippe Lang about 12 years ago
- Subject changed from changeset.rb RexexpError (Stack overflow in regexp matcher ... to RexexpError when parsing commit log with many #nnnn and ruby1.8
Reproduced with ruby1.8.7. FTR, no error is raised with ruby 1.9.2 or 1.9.3.
Updated by Cheyenne Wills about 12 years ago
Okay thank you.
Our workaround at the moment was to just look at the first 500 bytes of the log (that's "okay" for our users).
One possible solution would be to loop through the individual lines instead of the entire log at once
Updated by Go MAEDA almost 9 years ago
- Status changed from New to Closed
- Resolution set to Wont fix
Redmine has dropped support for Ruby 1.8.7 (#14371).