Skip to content

Commit

Permalink
Completely disable signal handler on 32-bit (#1488)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
binji authored Jul 21, 2020
1 parent 4942d3b commit cd5ff13
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions wasm2c/wasm-rt.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,28 +35,37 @@ extern "C" {
#define WASM_RT_MAX_CALL_STACK_DEPTH 500
#endif

/** Whether to enable memory checking via a signal handler.
/** Enable memory checking via a signal handler via the following definition:
*
* #define WASM_RT_MEMCHECK_SIGNAL_HANDLER 1
*
* This is usually 10%-25% faster, but requires OS-specific support.
* */

/** Check whether the signal handler is supported at all. */
#if (defined(__linux__) || defined(__unix__) || defined(__APPLE__)) && \
defined(__WORDSIZE) && __WORDSIZE == 64

/* If the signal handler is supported, then use it by default. */
#ifndef WASM_RT_MEMCHECK_SIGNAL_HANDLER
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER 1
#endif

#if WASM_RT_MEMCHECK_SIGNAL_HANDLER
#if defined(__linux__) || defined(__unix__) || defined(__APPLE__)
#if defined(__WORDSIZE) && __WORDSIZE != 64
#warning "Signal handler is only supported on 64-bit architectures"
#else
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX 1
#endif

#else
#error "No signal handler implementation for OS!"
#endif

/* The signal handler is not supported, error out if the user was trying to
* enable it. */
#if WASM_RT_MEMCHECK_SIGNAL_HANDLER
#error "Signal handler is not supported for this OS/Architecture!"
#endif

#ifndef WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER 0
#define WASM_RT_MEMCHECK_SIGNAL_HANDLER_POSIX 0

#endif

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

0 comments on commit cd5ff13

Please sign in to comment.