Project

General

Profile

Actions

Backport #6853

closed

Regular Expression Bug

Added by zhangb (Bushi Zhang) over 11 years ago. Updated over 11 years ago.

Status:
Closed
[ruby-core:47115]

Description

I'm getting a seg fault with the following code:

resources :products, :only => %w(show) do
collection do
get ':user_platform/:app_guid(/:template)', :action => 'index', :as => '',
:defaults => { :template => 'appwall' },
:constraints => { :user_platform => /[a-z][a-z0-9-\s]+/i, :app_guid => /[0-9a-z-.]+/i }
end
end

The culprit is the line with :constraints, specifically the trailing '-' in user_platform.

I tested the expression on Rubular and it's not a problem. Older versions of ruby will return a warning but won't crash. Removing the '-' fixes the problem.


Files

ruby_2012-08-10-115737_Bushis-MacBook-Pro.crash (19.5 KB) ruby_2012-08-10-115737_Bushis-MacBook-Pro.crash crashreporter zhangb (Bushi Zhang), 08/11/2012 01:22 AM
2012-08-10-crash.csv (164 KB) 2012-08-10-crash.csv output from console zhangb (Bushi Zhang), 08/11/2012 01:22 AM

Updated by zhangb (Bushi Zhang) over 11 years ago

Kindly ignore the rails code.

The problem is in:
/[a-z][a-z0-9-\s]+/i

Updated by sorah (Sorah Fukumori) over 11 years ago

  • ruby -v changed from ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-darwin11.3.0] to ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]

$ ruby -ve 'p /[a-z][a-z0-9-\s]+/i === "abcdef"'
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]
-e:1: warning: ambiguous first argument; put parentheses or even spaces
-e:1: warning: character class has '-' without escape: /[a-z][a-z0-9-\s]+/
ruby: [BUG] Segmentation fault
ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]

trunk seems fine, so please wait next 1.9.3 patch release.

Actions #3

Updated by mame (Yusuke Endoh) over 11 years ago

  • Tracker changed from Bug to Backport
  • Project changed from Ruby master to Backport193
  • Status changed from Open to Assigned
  • Assignee set to usa (Usaku NAKAMURA)

Usa-san, please pick out the patch for this issue from trunk!

--
Yusuke Endoh

Actions #4

Updated by usa (Usaku NAKAMURA) over 11 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r37172.
Bushi, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


merge revision(s) 37171:

* test/ruby/test_regexp.rb
  (TestRegexp#test_raw_hyphen_and_type_char_after_range): added new
  test. ref [ruby-core:47115] [Backport #6853]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0