Support custom stack guard size (#1368)
Add a new option WAMR_BUILD_STACK_GUARD_SIZE to set the custom stack guard size. For most RTOS systems, we use the native stack base address as the check boundary which may be not safe as POSIX based systems (like Linux).
This commit is contained in:
@ -343,12 +343,12 @@
|
||||
|
||||
/* Reserved bytes to the native thread stack boundary, throw native
|
||||
stack overflow exception if the guard boudary is reached */
|
||||
#ifndef RESERVED_BYTES_TO_NATIVE_STACK_BOUNDARY
|
||||
#ifndef WASM_STACK_GUARD_SIZE
|
||||
#if WASM_ENABLE_UVWASI != 0
|
||||
/* UVWASI requires larger native stack */
|
||||
#define RESERVED_BYTES_TO_NATIVE_STACK_BOUNDARY (4096 * 6)
|
||||
#define WASM_STACK_GUARD_SIZE (4096 * 6)
|
||||
#else
|
||||
#define RESERVED_BYTES_TO_NATIVE_STACK_BOUNDARY (1024)
|
||||
#define WASM_STACK_GUARD_SIZE (1024)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -189,9 +189,10 @@ wasm_exec_env_set_module_inst(WASMExecEnv *exec_env,
|
||||
void
|
||||
wasm_exec_env_set_thread_info(WASMExecEnv *exec_env)
|
||||
{
|
||||
uint8 *stack_boundary = os_thread_get_stack_boundary();
|
||||
exec_env->handle = os_self_thread();
|
||||
exec_env->native_stack_boundary = os_thread_get_stack_boundary()
|
||||
+ RESERVED_BYTES_TO_NATIVE_STACK_BOUNDARY;
|
||||
exec_env->native_stack_boundary =
|
||||
stack_boundary ? stack_boundary + WASM_STACK_GUARD_SIZE : NULL;
|
||||
}
|
||||
|
||||
#if WASM_ENABLE_THREAD_MGR != 0
|
||||
|
||||
Reference in New Issue
Block a user