Project

General

Profile

Backport #6853

Regular Expression Bug

Added by zhangb (Bushi Zhang) about 7 years ago. Updated almost 7 years ago.

Status:
Closed
Priority:
Normal
[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

Associated revisions

Revision 5ea65366
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37171 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37171
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

Revision 37171
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

Revision 37171
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

Revision 37171
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

Revision 37171
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

Revision 37171
Added by usa (Usaku NAKAMURA) almost 7 years ago

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

Revision cc251c2f
Added by usa (Usaku NAKAMURA) almost 7 years ago

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]

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37172 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37172
Added by usa (Usaku NAKAMURA) almost 7 years ago

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]

Revision 88e264d2
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • regparse.c (parse_char_class): also need to check the type of token after raw hyphen in regexp class, because the charcter code area is union'ed with the property of TK_CHAR_TYPE. reported by Bushi Zhang at [ruby-core:47115] [Backport #6853].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@37173 b2dd03c8-39d4-4d8f-98ff-823fe69b080e

Revision 37173
Added by usa (Usaku NAKAMURA) almost 7 years ago

  • regparse.c (parse_char_class): also need to check the type of token after raw hyphen in regexp class, because the charcter code area is union'ed with the property of TK_CHAR_TYPE. reported by Bushi Zhang at [ruby-core:47115] [Backport #6853].

History

Updated by zhangb (Bushi Zhang) about 7 years ago

Kindly ignore the rails code.

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

Updated by sorah (Sorah Fukumori) about 7 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.

#3

Updated by mame (Yusuke Endoh) almost 7 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 mame@tsg.ne.jp

#4

Updated by usa (Usaku NAKAMURA) almost 7 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]

Also available in: Atom PDF