Skip to content

Some regexps hang and eating 100% #9337

Closed

Description

@josser
  • Version: v7.0.0
  • Platform: Darwin josser-mbp 16.1.0 Darwin Kernel Version 16.1.0: Thu Oct 13 21:26:57 PDT 2016; root:xnu-3789.21.3~60/RELEASE_X86_64 x86_64
  • Subsystem: don't know, regexp?

Hi!
Not sure that this is correct place for such issue, because it looks more like v8 bug.
However, here is code which is stuck and never finished:

var r = new RegExp("^(http|https|ftp)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
var url = "http://www.something.com/bookstore/making-process-improvement-work-a-concise-action-guide-0132929554";
r.test(url);

Same code in chrome also eating 100% CPU and hang but not reproducible in safari or firefox.
That's why I think it's v8 issue.

Thank you and sorry for bad english :)

Activity

  1. added
    v8 engine
    on Oct 28, 2016
  2. benjamingr commented on Oct 28, 2016

    @benjamingr
    Member

    I can also reproduce this on earlier versions of Node

  3. added
    confirmed-bug
    on Oct 28, 2016
  4. cjihrig commented on Oct 28, 2016

    @cjihrig
    Contributor

    The nested *s and +s make this look like a ReDoS. I can reproduce the hang on Firefox as well.

  5. bnoordhuis commented on Oct 28, 2016

    @bnoordhuis
    Member

    V8 doesn't bail out on catastrophic backtracking like SM does (and presumably JSC too). See https://bugs.chromium.org/p/v8/issues/detail?id=287 and the many issues linked from it for more discussion.

    I'm going to close this because it's not under our control and the V8 team has stated they don't intend to change it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugv8 engine

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions