Skip to content

Commit cd5ff13

Browse files
authored
Completely disable signal handler on 32-bit (#1488)
The previous change prevented `WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX` from being defined, but `WASM_RT_MEMCHECK_SIGNAL_HANDLER` was still defined, which would prevent the memory bounds check.
1 parent 4942d3b commit cd5ff13

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

wasm2c/wasm-rt.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,28 +35,37 @@ extern "C" {
3535
#define WASM_RT_MAX_CALL_STACK_DEPTH 500
3636
#endif
3737

38-
/** Whether to enable memory checking via a signal handler.
38+
/** Enable memory checking via a signal handler via the following definition:
39+
*
40+
* #define WASM_RT_MEMCHECK_SIGNAL_HANDLER 1
3941
*
4042
* This is usually 10%-25% faster, but requires OS-specific support.
4143
* */
44+
45+
/** Check whether the signal handler is supported at all. */
46+
#if (defined(__linux__) || defined(__unix__) || defined(__APPLE__)) && \
47+
defined(__WORDSIZE) && __WORDSIZE == 64
48+
49+
/* If the signal handler is supported, then use it by default. */
4250
#ifndef WASM_RT_MEMCHECK_SIGNAL_HANDLER
4351
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER 1
4452
#endif
4553

4654
#if WASM_RT_MEMCHECK_SIGNAL_HANDLER
47-
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
48-
#if defined(__WORDSIZE) && __WORDSIZE != 64
49-
#warning "Signal handler is only supported on 64-bit architectures"
50-
#else
5155
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX 1
5256
#endif
57+
5358
#else
54-
#error "No signal handler implementation for OS!"
55-
#endif
59+
60+
/* The signal handler is not supported, error out if the user was trying to
61+
* enable it. */
62+
#if WASM_RT_MEMCHECK_SIGNAL_HANDLER
63+
#error "Signal handler is not supported for this OS/Architecture!"
5664
#endif
5765

58-
#ifndef WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX
66+
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER 0
5967
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX 0
68+
6069
#endif
6170

6271
/** Reason a trap occurred. Provide this to `wasm_rt_trap`. */

0 commit comments

Comments
 (0)