Status: New
Owner: ----

New issue 2912 by [email protected]: Regex explodes (100% CPU usage for 100 years)
http://code.google.com/p/v8/issues/detail?id=2912

I am not really sure what is your policy for such cases, but we encountered a situation when a node.js app was dead-hanging with 100% CPU usage when matching a user-supplied URL. The situation is fully reproducible in Chrome: DevTools start eating 100% CPU once this pattern match is made:

  1
2 var RE_URI = /\b((?:https?:\/\/|www\d{0,3}\.| [a-z0-9\.\-]+\.[a-z]{2,4}\/)(?:[^\s()<>]+|\(( [^\s()<>]+| (\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)| [^\s`!()\[\]{};:'". ,<>?«»“”‘’]))/gi;
  3
4 var match = RE_URI.exec('http://ru.wikipedia.org/wiki/%D0%9D%D0%BE%D1%80%D0%BC%D0%B0_(%D1% 85%D0%B0%D1%80%D0%B0%D0%BA%D1%82%D0%B5%D1%80%D0%B8%D1%81%D1%82%D0%B8%D0%BA%D0%B0)');
  5
  6 console.log(match); // like it ever happens


It is almost surely a complexity explosion as shortening the URL makes it hang for shorter time.

Of course, we'll use another regex.

Attachments:
        uri-hang.js  430 bytes

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to