Skip to content

Commit ea73484

Browse files
committed
Parser m_nextFunctionId is set incorrectly when skipping over nested function with functions in parameter scope
We use the deferred stubs to skip over nested functions and as part of skipping them, we adjust m_nextFunctionId so that other nested functions following the one we just skipped will have their function ids set correctly. We use the RestorePoint in the deferred stub to advance m_nextFunctionId by the function id increment amount. That's all fine unless the function we want to skip has nested functions in the parameter scope. Default argument assignments, for example. In that case, parsing or skipping the functions in the parameter scope would have already advanced m_nextFunctionId and so we end up setting it too high here. When we subsequently try and undefer one of the functions below the skipped one (one of the functions with a wrong function id), it might have a function id greater than the count of functions in the bytecode cache. Executing that function hits an assert in the bitvector we use to mark functions executed.
1 parent 9b71022 commit ea73484

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/Parser/Parse.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6175,6 +6175,11 @@ void Parser::ParseTopLevelDeferredFunc(ParseNodeFnc * pnodeFnc, ParseNodeFnc * p
61756175

61766176
this->GetScanner()->SeekTo(stub->restorePoint, m_nextFunctionId);
61776177

6178+
// If we already incremented m_nextFunctionId when we saw some functions in the parameter scope
6179+
// (in default argument assignment, for example), we want to remove the count of those so the
6180+
// function ids following the one we are skipping right now are correct.
6181+
*m_nextFunctionId -= pnodeFnc->nestedCount;
6182+
61786183
for (uint i = 0; i < stub->capturedNameCount; i++)
61796184
{
61806185
int stringId = stub->capturedNameSerializedIds[i];

0 commit comments

Comments
 (0)