Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
deps: update ChakraCore to chakra-core/ChakraCore@45a175d1c7
Browse files Browse the repository at this point in the history
[1.8>1.9] [MERGE #4612 @boingoing] OS#13976524: Force scanner to create pid for string constant trailing defer-parsed compact-body lambda

Merge pull request #4612 from boingoing:13976524

Lambda with compact-body which is defer-parsed and which is trailed immediately by a string constant can cause the string constant to miss having a pid created. When we try to load the string constant table in `ByteCodeGenerator`, we'll hit an AV with this pid being nullptr.

Fix by forcing the scanner to create a pid for this string constant - only for the single case of a string constant token immediately following the single-expression lambda body which is defer-parsed.

Test case looks like this:
```
jtmchw => z
'123'
```

Fixes:
https://microsoft.visualstudio.com/web/wi.aspx?id=13976524

Reviewed-By: chakrabot <chakrabot@users.noreply.github.com>
  • Loading branch information
boingoing authored and kfarnung committed Mar 7, 2018
1 parent 55e89c5 commit 4675b36
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions deps/chakrashim/core/lib/Parser/Parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7101,7 +7101,13 @@ void Parser::ParseExpressionLambdaBody(ParseNodePtr pnodeLambda)

IdentToken token;
charcount_t lastRParen = 0;

// We need to disable deferred parse mode in the scanner because the lambda body doesn't end with a right paren.
// The scanner needs to create a pid in the case of a string constant token immediately following the lambda body expression.
// Otherwise, we'll save null for the string constant pid which will AV during ByteCode generation.
BYTE fScanDeferredFlagsSave = m_pscan->SetDeferredParse(FALSE);
ParseNodePtr result = ParseExpr<buildAST>(koplAsg, nullptr, TRUE, FALSE, nullptr, nullptr, nullptr, &token, false, nullptr, &lastRParen);
m_pscan->SetDeferredParseFlags(fScanDeferredFlagsSave);

this->MarkEscapingRef(result, &token);

Expand Down
18 changes: 18 additions & 0 deletions deps/chakrashim/core/test/es6/bug_OS13976524.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------

WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js");

var tests = [
{
name: "Lambda with a string constant on the following line shouldn't AV",
body: function () {
jtmchw => z
'123'
}
},
];

testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" });
7 changes: 7 additions & 0 deletions deps/chakrashim/core/test/es6/rlexe.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,13 @@
<compile-flags>-force:deferparse -args summary -endargs</compile-flags>
</default>
</test>
<test>
<default>
<files>bug_OS13976524.js</files>
<tags>BugFix</tags>
<compile-flags>-force:deferparse -args summary -endargs</compile-flags>
</default>
</test>
<test>
<default>
<files>DeferParseLambda.js</files>
Expand Down

0 comments on commit 4675b36

Please sign in to comment.