New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 590864 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: Mar 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Mac
Pri: 2
Type: Bug



Sign in to add a comment

infinite loop with regex

Reported by muriloku...@gmail.com, Feb 29 2016

Issue description

Chrome Version       : 48.0.2564.116 (Official Build) m (32-bit)
URLs (if applicable) :
Other browsers tested:
  Add OK or FAIL, along with the version, after other browsers where you
have tested this issue:
     Safari:
    Firefox: 44.0.2 FAIL
         IE:

What steps will reproduce the problem?
run this code:
var result;
while(result = /my name/g.exec("my name is Murilo.")){
 console.log(result)
}


What is the expected result?
A result in console like this: ["my name", index: 0, input: "my name is Murilo."]

What happens instead?
It gets into a infinite loop

Please provide any additional information below. Attach a screenshot if
possible.
This code below works:
var result;
var regex = /my name/g
while(result = regex.exec("my name is Murilo.")){
 console.log(result)
}

but if I use /my name/g.exec() it gets into a loop.
 
Cc: rnimmagadda@chromium.org
Components: Platform>DevTools
Labels: M-50 Type-Bug Pri-2 OS-Linux OS-Mac OS-Windows
Status: Untriaged (was: Unconfirmed)
Able to repro this issue on Windows 7, MAC (10.11.3) & Ubuntu Trusty (14.04) for Google Chrome Stable Version - 48.0.2564.116

This is a Non-Regression issue existing from M30 - 30.0.1549.0
This is not a bug, please see this post for the reason why http://www.2ality.com/2013/08/regexp-g.html

Comment 3 by alph@chromium.org, Mar 8 2016

Components: -Platform>DevTools Platform>DevTools>JavaScript
Status: WontFix (was: Untriaged)
You create a new regex on each iteration, so it starts from scratch and matches the string every time. Not a bug.

Sign in to add a comment