Changeset 213452 in webkit


Ignore:
Timestamp:
Mar 6, 2017 8:57:11 AM (7 years ago)
Author:
Yusuke Suzuki
Message:

Null pointer crash when loading module with unresolved import also as a script file
https://bugs.webkit.org/show_bug.cgi?id=168971

Reviewed by Saam Barati.

JSTests:

  • stress/re-execute-error-module.js: Added.

(shouldBe):
(async):

  • stress/resources/error-module.js: Added.

Source/JavaScriptCore:

If linking throws an error, this error should be re-thrown
when requesting the same module.

  • builtins/ModuleLoaderPrototype.js:

(globalPrivate.newRegistryEntry):

  • runtime/JSModuleRecord.cpp:

(JSC::JSModuleRecord::link):

Location:
trunk
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/JSTests/ChangeLog

    r213313 r213452  
     12017-03-06  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Null pointer crash when loading module with unresolved import also as a script file
     4        https://bugs.webkit.org/show_bug.cgi?id=168971
     5
     6        Reviewed by Saam Barati.
     7
     8        * stress/re-execute-error-module.js: Added.
     9        (shouldBe):
     10        (async):
     11        * stress/resources/error-module.js: Added.
     12
    1132017-03-02  Keith Miller  <keith_miller@apple.com>
    214
  • trunk/Source/JavaScriptCore/ChangeLog

    r213450 r213452  
     12017-03-06  Yusuke Suzuki  <utatane.tea@gmail.com>
     2
     3        Null pointer crash when loading module with unresolved import also as a script file
     4        https://bugs.webkit.org/show_bug.cgi?id=168971
     5
     6        Reviewed by Saam Barati.
     7
     8        If linking throws an error, this error should be re-thrown
     9        when requesting the same module.
     10
     11        * builtins/ModuleLoaderPrototype.js:
     12        (globalPrivate.newRegistryEntry):
     13        * runtime/JSModuleRecord.cpp:
     14        (JSC::JSModuleRecord::link):
     15
    1162017-03-06  Yusuke Suzuki  <utatane.tea@gmail.com>
    217
  • trunk/Source/JavaScriptCore/builtins/ModuleLoaderPrototype.js

    r211018 r213452  
    9393        key: key,
    9494        state: @ModuleFetch,
    95         metadata: @undefined,
    9695        fetch: @undefined,
    9796        instantiate: @undefined,
     
    10099        dependenciesMap: @undefined,
    101100        module: @undefined, // JSModuleRecord
    102         error: @undefined,
     101        linkError: @undefined,
     102        linkSucceeded: true,
    103103    };
    104104}
     
    351351    "use strict";
    352352
    353     // FIXME: Current implementation does not support optionalInstance.
    354     // So Link's step 3 is skipped.
    355     // https://bugs.webkit.org/show_bug.cgi?id=148171
    356 
     353    if (!entry.linkSucceeded)
     354        throw entry.linkError;
    357355    if (entry.state === @ModuleReady)
    358356        return;
    359357    @setStateToMax(entry, @ModuleReady);
    360358
    361     // Since we already have the "dependencies" field,
    362     // we can call moduleDeclarationInstantiation with the correct order
    363     // without constructing the dependency graph by calling dependencyGraph.
    364     var dependencies = entry.dependencies;
    365     for (var i = 0, length = dependencies.length; i < length; ++i) {
    366         var pair = dependencies[i];
    367         this.link(pair.value.registryEntry, fetcher);
    368     }
    369 
    370     this.moduleDeclarationInstantiation(entry.module, fetcher);
     359    try {
     360        // Since we already have the "dependencies" field,
     361        // we can call moduleDeclarationInstantiation with the correct order
     362        // without constructing the dependency graph by calling dependencyGraph.
     363        var dependencies = entry.dependencies;
     364        for (var i = 0, length = dependencies.length; i < length; ++i) {
     365            var pair = dependencies[i];
     366            this.link(pair.value.registryEntry, fetcher);
     367        }
     368
     369        this.moduleDeclarationInstantiation(entry.module, fetcher);
     370    } catch (error) {
     371        entry.linkSucceeded = false;
     372        entry.linkError = error;
     373        throw error;
     374    }
    371375}
    372376
  • trunk/Source/JavaScriptCore/runtime/JSModuleRecord.cpp

    r211247 r213452  
    8787        return;
    8888    }
     89    instantiateDeclarations(exec, executable);
     90    RETURN_IF_EXCEPTION(scope, void());
    8991    m_moduleProgramExecutable.set(vm, this, executable);
    90     instantiateDeclarations(exec, executable);
    9192}
    9293
Note: See TracChangeset for help on using the changeset viewer.