Issue Details (XML | Word | Printable)

Key: JRUBY-2780
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Marcin Mielzynski
Reporter: Brian Tatnall
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
JRuby

RegexpError: target of repeat operator is invalid

Created: 11/Jul/08 12:08 PM   Updated: 12/Jan/09 04:27 PM
Component/s: Core Classes/Modules
Affects Version/s: JRuby 1.1.2
Fix Version/s: JRuby 1.1.6

Time Tracking:
Not Specified

Environment: jruby 1.1.2


 Description  « Hide
Using autotest for an rspec based project when errors occur there is a Regexp that raises an error in Jruby while no error is raised in MRI.

ruby -e "/\n(\.\/)?(.*\.rb):[\d]+:\Z?/"

jruby -e "/\n(\.\/)?(.*\.rb):[\d]+:\Z?/"
-e:1: target of repeat operator is invalid: /\n(\.\/)?(.*\.rb):[\d]+:\Z?/ (RegexpError)

Rubinius has the same bug found here:
http://rubinius.lighthouseapp.com/projects/5089-rubinius/tickets/587-regexperror-target-of-repeat-operator-is-invalid

Backtrace:
/mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/autotest/rspec.rb:30:in `consolidate_failures': target of repeat operator is invalid: /\n(\.\/)?(.*\.rb):[\d]+:\Z?/ (RegexpError)
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/autotest/rspec.rb:30:in `each'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/rspec-1.1.4/lib/autotest/rspec.rb:30:in `consolidate_failures'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:401:in `handle_results'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:274:in `run_tests'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:228:in `get_to_green'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:208:in `run'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:206:in `loop'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:206:in `run'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/lib/autotest.rb:136:in `run'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest:55:in `/mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest'
from /mnt/intex/jruby/jruby-1.1.2/lib/ruby/gems/1.8/gems/ZenTest-3.10.0/bin/autotest:19:in `load'
from /mnt/intex/jruby/jruby-1.1.2/bin/autotest:19



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Charles Oliver Nutter added a comment - 11/Jul/08 07:02 PM
I think this has come up before and it may be an Oniguruma/Joni bug. Rubinius and Ruby 1.9 use Oniguruma, and both show the issue.

Brian Tatnall added a comment - 15/Jul/08 01:15 PM
Yeah, I didn't check 1.9, but the same error in Rubinius had me guessing Joni. I searched and couldn't find the issue anywhere in JRuby's issues. Better to have it documented I guess.

Charles Oliver Nutter added a comment - 16/Jul/08 12:28 AM
Punting...not very critical, and it's an issue shared with Oniguruma. Downgrading to "major".

Marcin Mielzynski added a comment - 16/Jul/08 04:58 AM
The issue is that Oniguruma treats quantifiers applied to anchors as invalid ones. This can be easily turned of, though, the problem is that e.g. \z+ has kind of undefined behavior (it differs among perl, ptyhon, ruby, etc).
The good news is that when this check is turned off Joni matches MRI successful matches in all weird cases (the only difference is the string index returned as a match).
"\n\n\na" =~ /a/ => 3
"\n\n\na" =~ /a\z?/ => 0

JRuby would return 3 in both cases.


Charles Oliver Nutter added a comment - 16/Jul/08 05:15 PM
Marcin: Is this a behavior we could have turned off by default in 1.8 mode and turned on in 1.9 mode? That would eliminate it as an incompatibility for apps that are using \z.

Marcin Mielzynski added a comment - 16/Jul/08 07:20 PM
There is absolutely no problem doing so (via flag in RubyInstanceConfig), though, I'd guess Oniguruma on it's own or Rubinius guys are going to match 1.8 anyways here (so 1.9 is more likely to match 1.8 imho).

Marcin Mielzynski added a comment - 16/Jul/08 07:22 PM
More precisely: (1.9 is more likely going to match 1.8 imho).

Marcin Mielzynski added a comment - 30/Nov/08 10:52 AM
Turned out to be true, 1.9 just got a fix that allows this. Applying the exact same fix to joni (only for non-vanilla mode).

Marcin Mielzynski added a comment - 30/Nov/08 01:08 PM
Fixed in r8218-r8220. We'll match 1.9 on all edge cases.