1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-30 16:40:57 -05:00

fix: Don't panic when a worker is closed in the reactions to a wasm operation. (#12270)

This commit is contained in:
Andreu Botella 2021-09-30 19:52:58 +02:00 committed by Ryan Dahl
parent b1eeaf71ff
commit c79fd8f419
5 changed files with 41 additions and 0 deletions

View file

@ -1204,6 +1204,11 @@ itest!(worker_message_before_close {
output: "worker_message_before_close.js.out", output: "worker_message_before_close.js.out",
}); });
itest!(worker_close_in_wasm_reactions {
args: "run --quiet --reload --allow-read worker_close_in_wasm_reactions.js",
output: "worker_close_in_wasm_reactions.js.out",
});
#[test] #[test]
fn no_validate_asm() { fn no_validate_asm() {
let output = util::deno_cmd() let output = util::deno_cmd()

View file

@ -0,0 +1,10 @@
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
// https://github.com/denoland/deno/issues/12263
// Test for a panic that happens when a worker is closed in the reactions of a
// WASM async operation.
new Worker(
new URL("./workers/close_in_wasm_reactions.js", import.meta.url),
{ type: "module" },
);

View file

@ -0,0 +1 @@
Error: CompileError: WebAssembly.compile(): expected string length @+10

View file

@ -0,0 +1,21 @@
// https://github.com/denoland/deno/issues/12263
// Test for a panic that happens when a worker is closed in the reactions of a
// WASM async operation.
// The minimum valid wasm module, plus two additional zero bytes.
const buffer = new Uint8Array([
0x00,
0x61,
0x73,
0x6D,
0x01,
0x00,
0x00,
0x00,
0x00,
0x00,
]);
WebAssembly.compile(buffer).catch((err) => {
console.log("Error:", err);
self.close();
});

View file

@ -1549,6 +1549,10 @@ impl JsRuntime {
return exception_to_err_result(tc_scope, exception, false); return exception_to_err_result(tc_scope, exception, false);
} }
if tc_scope.has_terminated() || tc_scope.is_execution_terminating() {
break;
}
let is_done = is_done.unwrap(); let is_done = is_done.unwrap();
if is_done.is_true() { if is_done.is_true() {
break; break;