Skip to content

Commit 6a6ba18

Browse files
committed
OS#17830745 - ASSERT: childModuleRecord->WasParsed() (chakra!<lambda_dd028cf82b8b597299372d12cc6b9c81>::operator()+84
If a parent module has multiple children and one child fails to load (results in error) but children which resolve later succeed, we will attempt to instantiate the parent module anyway because we forget that a previous child failed. ```javascript import { default as d0 } from 'module0.js'; import { default as d1 } from 'module1.js'; // module1.js doesn't exist or otherwise results in error ``` In above, we resolve children modules from bottom-up so module1.js is resolved first. Since it results in an error we'll save the error in our parent module. Next we'll continue to resolve module0.js which parses successfully. Since the child didn't result in an error, we'll attempt to instantiate the parent module but not all children were parsed so we'll hit an assert. Attempt to fix this by checking to see if parent module already has an error before calling to instantiate the parent module. Fixes: https://microsoft.visualstudio.com/OS/_workitems/edit/17830745
1 parent 40a21ee commit 6a6ba18

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

lib/Runtime/Language/SourceTextModuleRecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ namespace Js
367367
{
368368
OUTPUT_TRACE_DEBUGONLY(Js::ModulePhase, _u("OnChildModuleReady(%s)\n"), this->GetSpecifierSz(), childModule->GetSpecifierSz());
369369
HRESULT hr = NOERROR;
370-
if (childException != nullptr)
370+
if (childException != nullptr || this->errorObject != nullptr)
371371
{
372372
// propagate the error up as needed.
373373
if (this->errorObject == nullptr)

test/es6module/bug_OS17830745.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//-------------------------------------------------------------------------------------------------------
2+
// Copyright (C) Microsoft. All rights reserved.
3+
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
4+
//-------------------------------------------------------------------------------------------------------
5+
6+
// Resolving module2 will result in error (can't find the module file).
7+
// This causes us to mark module3 as having an error.
8+
// Later we resolve module0 which parses correctly.
9+
// This causes us to notify parents which will try to instantiate module3 because
10+
// module0 did not have an error. However, module3 has children modules which were
11+
// not parsed. That put module3 into error state, we should skip instantiating
12+
// module3.
13+
14+
WScript.RegisterModuleSource('module0_e0565b64-3435-42c1-ad1f-6376fb7af915.js', `
15+
console.log('fail');`);
16+
WScript.RegisterModuleSource('module3_65eb7cb0-2a92-4a34-a368-2cfc1d6a3768.js', `import {
17+
default as module3_localbinding_0,
18+
default as module3_localbinding_1
19+
} from 'module0_e0565b64-3435-42c1-ad1f-6376fb7af915.js';
20+
export { } from 'module2_894411c7-94ec-4069-b8e1-10ab0d881f6e.js';
21+
console.log('fail');`);
22+
WScript.LoadScriptFile('module3_65eb7cb0-2a92-4a34-a368-2cfc1d6a3768.js', 'module');
23+
console.log('pass');

test/es6module/rlexe.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,4 +161,11 @@
161161
<tags>exclude_jshost</tags>
162162
</default>
163163
</test>
164+
<test>
165+
<default>
166+
<files>bug_OS17830745.js</files>
167+
<compile-flags>-MuteHostErrorMsg</compile-flags>
168+
<tags>exclude_sanitize_address</tags>
169+
</default>
170+
</test>
164171
</regress-exe>

0 commit comments

Comments
 (0)