WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
67455
Different regular expression result
https://bugs.webkit.org/show_bug.cgi?id=67455
Summary
Different regular expression result
Dave Mandelin
Reported
2011-09-01 17:01:58 PDT
This is
https://bugzilla.mozilla.org/show_bug.cgi?id=683838
In JSC: var rg = /(X(?:.(?!X))*?Y)|(Y(?:.(?!Y))*?Z)/g; var str = "Y aaa X Match1 Y aaa Y Match2 Z"; print(str.match(rg)); ==> Y Match2 Z should be ==> X Match1 Y,Y Match2 Z
Attachments
Patch, needs change log & layout test
(2.08 KB, patch)
2011-10-02 12:16 PDT
,
Gavin Barraclough
no flags
Details
Formatted Diff
Diff
Fix
(5.53 KB, patch)
2011-10-02 15:36 PDT
,
Gavin Barraclough
darin
: review+
Details
Formatted Diff
Diff
Show Obsolete
(1)
View All
Add attachment
proposed patch, testcase, etc.
Julien Chaffraix
Comment 1
2011-09-02 09:22:05 PDT
Confirmed on ToT for JSC. V8 is not impacted nor is Opera or IE.
Gavin Barraclough
Comment 2
2011-09-29 22:51:10 PDT
Reduction: print(/a|b(?:[^b])*?c/.exec("badbc")); should print a, prints bc.
Gavin Barraclough
Comment 3
2011-10-02 11:37:19 PDT
Looks like the problem is in YARR interpreter, in backtrackParentheses with QuantifierNonGreedy, and where the expression is passed input to match against that will match the parentheses more than once but then fail. For the above reduction I believe the interpreter will have torn off a couple of disjunction contexts (recording the matches of 'a' and 'd'), but only one of these contexts gets backtracked back into. Since the minimum size of these matches is one, failing to backtrack means the input position has not been reverted correctly. When the match has failed starting at input position 0, we try again at input +1, but instead of starting at position 1 the second pass starts at position 2, hence the first alternative doesn't get a chance to match.
Gavin Barraclough
Comment 4
2011-10-02 12:01:29 PDT
The bug was introduced by
r72140
. It added a return to the backtracking loop for backtrackParentheses/QuantifierNonGreedy, so it always returns after one iteration. We've already returned if the match succeeded, the additional return should only be triggered if an error is detected.
Gavin Barraclough
Comment 5
2011-10-02 12:16:40 PDT
Created
attachment 109427
[details]
Patch, needs change log & layout test
Gavin Barraclough
Comment 6
2011-10-02 15:36:23 PDT
Created
attachment 109429
[details]
Fix
WebKit Review Bot
Comment 7
2011-10-02 15:38:48 PDT
Attachment 109429
[details]
did not pass style-queue: Failed to run "['Tools/Scripts/check-webkit-style', '--diff-files', u'LayoutTests/ChangeLog', u'LayoutTests/fast..." exit_code: 1 LayoutTests/ChangeLog:1: ChangeLog entry has no bug number [changelog/bugnumber] [5] Source/JavaScriptCore/ChangeLog:1: ChangeLog entry has no bug number [changelog/bugnumber] [5] Total errors found: 2 in 5 files If any of these errors are false positives, please file a bug against check-webkit-style.
Gavin Barraclough
Comment 8
2011-10-02 17:26:35 PDT
Fixed in
r96479
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug