-
Notifications
You must be signed in to change notification settings - Fork 864
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rhino 1.7.7.2 can cause heap space (OutOfMemoryError) due to infinite loop on parsing #323
Comments
According to some work with 'git bisect,' the problem was introduced here: It's not clear to me what changed here and why it would cause this, however, so if anyone else has an idea then we can resolve this. |
The minimal test source is just a right parenthesis: The
Now in the case of just a
diff --git a/src/org/mozilla/javascript/Parser.java b/src/org/mozilla/javascript/Parser.java
index f8b64d14..7aa5f963 100644
--- a/src/org/mozilla/javascript/Parser.java
+++ b/src/org/mozilla/javascript/Parser.java
@@ -3064,9 +3064,6 @@ public class Parser
pos = ts.tokenBeg; end = ts.tokenEnd;
return new KeywordLiteral(pos, end - pos, tt);
- case Token.RP:
- return new EmptyExpression();
-
case Token.RESERVED:
consumeToken();
reportError("msg.reserved.id");
@@ -3099,7 +3096,7 @@ public class Parser
Comment jsdocNode = getAndResetJsDoc();
int lineno = ts.lineno;
int begin = ts.tokenBeg;
- AstNode e = expr();
+ AstNode e = (peekToken() == Token.RP ? new EmptyExpression() : expr());
if (peekToken() == Token.FOR) {
return generatorExpression(e, begin);
} After this change all tests still pass, but it's possible that now broken cases (particularly for arrow function) are just not covered yet. |
After digging through the code I'm not sure that I can suggest a better fix than this one. Perhaps we will work on a version of this and then run further tests. |
This pull request addresses the problem by including your patch and a test case. As you say, it passes the Rhino tests, but we don't know if there are other parsing bugs triggered when error recovery is turned on. Are you able to test this out in your environment? It'd be a big help. Thanks! |
We closed pull request #334 and at least this particular use case works now. I'm going to close this, but please open a new one if something else happens. |
With Rhino 1.7.7.2 parsing the following syntactically false JavaScript function call causes a
OutOfMemoryError
, due to an infinite loop.Error report:
missing ) after argument list, 0, 35.
missing ; before statement, 0, 35.
missing ; before statement, 0, 37.
missing ; before statement, 0, 100.
missing ; before statement, 0, 100.
missing ; before statement, 0, 100.
missing ; before statement, 0, 100.
missing ; before statement, 0, 100.
... [infinite loop]
With Rhino 1.7.7.1 no infinite loop occurs while executing the code.
missing ) after argument list, 0, 35.
missing ; before statement, 0, 35.
missing ; before statement, 0, 37.
missing ; before statement, 0, 100.
syntax error, 0, 100.
The text was updated successfully, but these errors were encountered: