Comment #3 on issue 1888 by [email protected]: RegExp runs infinitely in
Chrome
http://code.google.com/p/v8/issues/detail?id=1888
Your RegExp hits what it traditionally called "catastrophic backtracking" .
That means that it keeps retrying different ways to parse the same string,
and fail. This can take extremely long to get through (seemingly, and
practically, infinitely long).
It's caused by repeating quantifiers, like the "(...|...+)+" that occurs
three times in the above example, and it can usually be avoided by
rewriting the RegExp.
In this case, if I interpret the RegExp correctly, the first of those
plusses can be removed without changing the meaning of the RegExp, since
the alternatives are always disjoint, so you get:
/((?:\((?:\([^()]+\)|[^()])+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|
[^\[\]'"])+\]|\\.|[^ >+~,(\[\\])+|[>+~])(\s*,\s*)?((?:.|\r|
\n)*)/g.exec("[onclick^=\"window.open('http://www.firstload.de/\"]");
If you run that, it ends quickly with the correct result, which is NOT null
I.e., Safari and Firefox simply abort the RegExp execution and return
null , even though the RegExp really does match the string (technically a
spec-violation :).
V8 doesn't abort and instead relies on the embedder to interrupt it just as
any other long-running JavaScript process.
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev