Closed
Bug 375642
Opened 17 years ago
Closed 17 years ago
Another regexp that makes JS allocate >1GB and hang
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
VERIFIED
FIXED
People
(Reporter: jruderman, Assigned: crowderbt)
References
Details
(Keywords: hang, testcase)
Attachments
(1 file)
1.71 KB,
patch
|
mrbkap
:
review+
|
Details | Diff | Splinter Review |
This makes the JavaScript engine allocate gobs of memory and hang for a while: /(?:a??)+?/.exec("") options("relimit") does not help.
Comment 1•17 years ago
|
||
With the following regexp : var regexp= /^(?:[\w!#$%&'*+/=?^_`{|}~-]+\.?)*[\w!#$%&'*+/=?^_`{|}~]+@(?:(?:[a-z\d]+-?)*[a-z\d]+\.)+[a-z]{2,5}$/; regexp.test("test60%OffOnPanties.yeah-baby@yop.reduction.com") returns true as expected, but regexp.test("test60%OffOnPanties.yeah-baby@yop.%reduction.com") hangs the javascript instead of returning false. The alert asking if you want to continue/debug/stop the script shows up. (the used regexp is trying to validate email adress as specified in RFC3696 with a restrcition : "abc def@ghi"@example.com is not supported) Is this the same bug ?
Comment 2•17 years ago
|
||
Please notice I have the bug on W2k/Firefox 2.0.0.3
Assignee | ||
Comment 3•17 years ago
|
||
Joachim: Your bug is a different one, which has been resolved on the trunk. Your regular expression is exponentially complex; on the trunk this issue is helped by a JavaScript option to throw an exception on expressions that are performing badly. If your expression contains a structure like this: (.*)*, then you probably have this problem. Looking at your expression, it is possible you have used "*" characters in places where you meant to use "\*", and you are definitely doing this: ([...]+)*, which is has the same non-linear performance characteristics as (.*)*. You can and should refactor your expression to operate in linear time. I was able to get better results with this: js> "test60%OffOnPanties.yeah-baby@yop.reduction.com".match(/^(?:[\w!#$%&'\*+/=?^_`{|}~-\.]+)[\w!#$%&'*+/=?^_`{|}~]+@(?:(?:[a-z\d]+-?)*[a-z\d]+\.)+[a-z]{2,5}$/) test60%OffOnPanties.yeah-baby@yop.reduction.com (essentially, I made the first parenthesized expression not have a "*" after it, and moved the \. inside the [] group). Let me know if that works better for you.
Assignee | ||
Comment 4•17 years ago
|
||
The new expression does reject "test60%OffOnPanties.yeah-baby@yop.%reduction.com" and I think you intended, also.
Assignee | ||
Updated•17 years ago
|
Assignee: general → crowder
Assignee | ||
Comment 5•17 years ago
|
||
mrbkap: Let me know when the running them on these gets boring. Also added some assertions for fruity goodness.
Attachment #260769 -
Flags: review?(mrbkap)
Assignee | ||
Updated•17 years ago
|
Status: NEW → ASSIGNED
OS: Mac OS X → All
Hardware: PC → All
Comment 6•17 years ago
|
||
Comment on attachment 260769 [details] [diff] [review] Yet another empty result, infinite loop Maybe it might be worth to investigate making REOP_EMPTY work after all?
Attachment #260769 -
Flags: review?(mrbkap) → review+
Assignee | ||
Comment 7•17 years ago
|
||
No, I think the removal of REOP_EMPTY is a good optimization, and going back now is more pain than fixing the one or two more (if any?) endpoints like this that don't do the proper checking.
Assignee | ||
Comment 8•17 years ago
|
||
jsregexp.c: 3.145
Assignee | ||
Updated•17 years ago
|
Status: ASSIGNED → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Comment 9•17 years ago
|
||
/cvsroot/mozilla/js/tests/ecma_3/RegExp/regress-375642.js,v <-- regress-375642.js initial revision: 1.1
Flags: in-testsuite+
You need to log in
before you can comment on or make changes to this bug.
Description
•