Commit 54a30270 authored by Michael Starzinger's avatar Michael Starzinger Committed by Commit Bot

[asm.js] Gracefully handle stack overflow in start function.

R=clemensh@chromium.org
TEST=mjsunit/regress/regress-crbug-762472
BUG=chromium:762472

Change-Id: I8977fb9c9330f03641291b08cf803d0117b7a96a
Reviewed-on: https://chromium-review.googlesource.com/652478Reviewed-by: 's avatarClemens Hammacher <clemensh@chromium.org>
Commit-Queue: Michael Starzinger <mstarzinger@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47852}
parent 5fe0c6c6
......@@ -377,7 +377,9 @@ MaybeHandle<Object> AsmJs::InstantiateAsmWasm(Isolate* isolate,
MaybeHandle<Object> maybe_module_object =
wasm::SyncInstantiate(isolate, &thrower, module, foreign, memory);
if (maybe_module_object.is_null()) {
DCHECK(!isolate->has_pending_exception());
// An exception caused by the module start function will be set as pending
// and bypass the {ErrorThrower}, this happens in case of a stack overflow.
if (isolate->has_pending_exception()) isolate->clear_pending_exception();
thrower.Reset(); // Ensure exceptions do not propagate.
ReportInstantiationFailure(script, position, "Internal wasm failure");
return MaybeHandle<Object>();
......
// Copyright 2017 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --stack-size=100
function Module() {
"use asm";
function f() {}
return { f:f }
}
function InstantiateNearStackLimit() {
try {
var fuse = InstantiateNearStackLimit();
if (fuse == 0) Module();
return fuse - 1;
} catch(e) {
return init_fuse;
}
}
var init_fuse = 0;
for (init_fuse = 0; init_fuse < 10; init_fuse++) {
InstantiateNearStackLimit();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment