Skip to content

Commit 46695b9

Browse files
authored
EH: Use the consistent type for EH handlers (#3619)
The "handlers" on the interpreter stack is sometimes treated as host pointers and sometimes treated as i64 values. It's quite broken for targets where pointers are not 64-bit. This commit makes them host pointers consistently. (at least for 32-bit and 64-bit pointers. We don't support other pointer sizes anyway.) Fixes #3110
1 parent 1b1ec71 commit 46695b9

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

core/iwasm/interpreter/wasm_interp_classic.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,12 @@ wasm_interp_get_frame_ref(WASMInterpFrame *frame)
495495
} while (0)
496496
#endif
497497

498+
#if UINTPTR_MAX == UINT64_MAX
499+
#define PUSH_PTR(value) PUSH_I64(value)
500+
#else
501+
#define PUSH_PTR(value) PUSH_I32(value)
502+
#endif
503+
498504
/* in exception handling, label_type needs to be stored to lookup exception
499505
* handlers */
500506

@@ -1892,19 +1898,19 @@ wasm_interp_call_func_bytecode(WASMModuleInstance *module,
18921898
switch (handler_opcode) {
18931899
case WASM_OP_CATCH:
18941900
skip_leb(lookup_cursor); /* skip tag_index */
1895-
PUSH_I64(end_addr);
1901+
PUSH_PTR(end_addr);
18961902
break;
18971903
case WASM_OP_CATCH_ALL:
1898-
PUSH_I64(end_addr);
1904+
PUSH_PTR(end_addr);
18991905
break;
19001906
case WASM_OP_DELEGATE:
19011907
skip_leb(lookup_cursor); /* skip depth */
1902-
PUSH_I64(end_addr);
1908+
PUSH_PTR(end_addr);
19031909
/* patch target_addr */
19041910
(frame_csp - 1)->target_addr = lookup_cursor;
19051911
break;
19061912
case WASM_OP_END:
1907-
PUSH_I64(0);
1913+
PUSH_PTR(0);
19081914
/* patch target_addr */
19091915
(frame_csp - 1)->target_addr = end_addr;
19101916
break;

0 commit comments

Comments
 (0)