Skip to content

Commit 8e214ec

Browse files
thibaudmichaudV8 LUCI CQ
authored andcommitted
[wasm][exnref] Fix catchless try_table
If the try_table does not have a catch handler, we don't update the {current_catch_} index or set the {previous_catch} field of the block when we enter it. Therefore also skip the reverse operation when the block ends. R=clemensb@chromium.org Fixed: 372261626 Change-Id: Ib3a23e32f9d0ec153d6a00733d96b52cf040e8bd Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/5920086 Commit-Queue: Thibaud Michaud <thibaudm@chromium.org> Reviewed-by: Clemens Backes <clemensb@chromium.org> Cr-Commit-Position: refs/heads/main@{#96481}
1 parent 91ecb03 commit 8e214ec

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

src/wasm/function-body-decoder-impl.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3511,7 +3511,11 @@ class WasmFullDecoder : public WasmDecoder<ValidationTag, decoding_mode> {
35113511
if (!VALIDATE(TypeCheckOneArmedIf(c))) return 0;
35123512
}
35133513
if (c->is_try_table()) {
3514-
current_catch_ = c->previous_catch;
3514+
// "Pop" the {current_catch_} index. We did not push it if the block has
3515+
// no handler, so also skip it here in this case.
3516+
if (c->catch_cases.size() > 0) {
3517+
current_catch_ = c->previous_catch;
3518+
}
35153519
FallThrough();
35163520
// Temporarily set the reachability for the catch handlers, and restore
35173521
// it before we actually exit the try block.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Copyright 2024 the V8 project authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
// Flags: --experimental-wasm-exnref
6+
7+
d8.file.execute("test/mjsunit/wasm/wasm-module-builder.js");
8+
9+
let builder = new WasmModuleBuilder();
10+
let tag = builder.addTag(kSig_v_v);
11+
builder.addFunction("main", kSig_v_v)
12+
.addBody([
13+
kExprTry, kWasmVoid,
14+
kExprTryTable, kWasmVoid, 0,
15+
kExprEnd,
16+
kExprThrow, tag,
17+
kExprCatchAll,
18+
kExprEnd
19+
]).exportFunc();
20+
let instance = builder.instantiate();
21+
assertDoesNotThrow(instance.exports.main);

0 commit comments

Comments
 (0)