Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 433893

Summary: Infinite loop recovering from broken escaped identifier
Product: [ECD] Orion Reporter: Michael Rennie <Michael_Rennie>
Component: JS ToolsAssignee: Michael Rennie <Michael_Rennie>
Status: RESOLVED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: mamacdon
Version: unspecified   
Target Milestone: 6.0 M2   
Hardware: All   
OS: All   
Whiteboard:

Description Michael Rennie CLA 2014-04-30 14:35:34 EDT
Consider the following snippet:

var v = {a b:{cc:3, dd:"hey" e} c:2};function f() {return {a b:{cc:3, dd:"hey" e} c:2};}

Steps:

1. edit the last "hey" to be "hey\''
2. edit the last "hey" to be \'hey\''
3. hang

Similar problem to bug 433709 - while trying to recover from a completely broken object property we are failing to collect the next token and advance the state because a nested error is thrown.

The stack trace:

throwError (esprima.js:1839)
getEscapedIdentifier (esprima.js:549)
scanIdentifier (esprima.js:612)
advance (esprima.js:1278)
collectToken (esprima.js:1314)
lex (esprima.js:1342)
parsePrimaryExpression (esprima.js:2265)
parseLeftHandSideExpressionAllowCall (esprima.js:2367)
parsePostfixExpression (esprima.js:2422)
parseUnaryExpression (esprima.js:2477)
parseBinaryExpression (esprima.js:2566)
parseConditionalExpression (esprima.js:2632)
parseAssignmentExpression (esprima.js:2658)
parseExpression (esprima.js:2685)
(anonymous function) (esprima.js:4038)
parseStatement (esprima.js:3364)
(anonymous function) (esprima.js:4053)
parseSourceElement (esprima.js:3609)
parseFunctionSourceElements (esprima.js:3435)
parseFunctionDeclaration (esprima.js:3536)
parseSourceElement (esprima.js:3602)
parseSourceElements (esprima.js:3642)
parseProgram (esprima.js:3658)
parse (esprima.js:3927)
Objects.mixin.parse (astManager.js:71)
(anonymous function) (astManager.js:59)
settleDeferred (Deferred.js:71)
notify (Deferred.js:145)
run (Deferred.js:29)
Comment 1 Michael Rennie CLA 2014-05-01 12:47:35 EDT
Fix + tests pushed to: http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=2b6a651e2b515cdffe628f7001e5af6393b34372

There are some pretty ugly cascading errors reported, but they are just the errors reported from Esprima. I'll update them to be saner in bug 433442.
Comment 2 Michael Rennie CLA 2014-05-01 16:02:06 EDT
While I was doing some additional testing I managed to get into another loop. So I took a step back and came up with a better general fix to prevent these problems (on top of the additional recovery):

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=a636147d9af3044940e481751a6e367f1919f60e