Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix native stack overflow check failed in interpreter #992

Merged
merged 3 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix stack overflow of uvwasi
  • Loading branch information
wenyongh committed Jan 29, 2022
commit 4b0a483c920eae296bacfe32e03eb5fc834068b6
7 changes: 7 additions & 0 deletions core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@
#define WASM_THREAD_AUX_STACK_SIZE_MIN (256)

/* Default/min/max stack size of each app thread */
#if !(defined(APP_THREAD_STACK_SIZE_DEFAULT) \
&& defined(APP_THREAD_STACK_SIZE_MIN))
#if defined(BH_PLATFORM_ZEPHYR) || defined(BH_PLATFORM_ALIOS_THINGS) \
|| defined(BH_PLATFORM_ESP_IDF) || defined(BH_PLATFORM_OPENRTOS)
#define APP_THREAD_STACK_SIZE_DEFAULT (6 * 1024)
Expand All @@ -297,16 +299,21 @@
#define APP_THREAD_STACK_SIZE_DEFAULT (32 * 1024)
#define APP_THREAD_STACK_SIZE_MIN (24 * 1024)
#endif
#endif
#if !defined(APP_THREAD_STACK_SIZE_MAX)
#define APP_THREAD_STACK_SIZE_MAX (8 * 1024 * 1024)
#endif

/* 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
#define RESERVED_BYTES_TO_NATIVE_STACK_BOUNDARY (512)
#endif

/* Guard page count for stack overflow check with hardware trap */
#ifndef STACK_OVERFLOW_CHECK_GUARD_PAGE_COUNT
#define STACK_OVERFLOW_CHECK_GUARD_PAGE_COUNT 3
#endif

/* Default wasm block address cache size and conflict list size */
#ifndef BLOCK_ADDR_CACHE_SIZE
Expand Down
4 changes: 2 additions & 2 deletions core/shared/platform/android/platform_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef pthread_t korp_thread;

#define bh_socket_t int

#if WASM_DISABLE_HW_BOUND_CHECK == 0
#if WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|| defined(BUILD_TARGET_AARCH64) || defined(BUILD_TARGET_RISCV64_LP64D) \
|| defined(BUILD_TARGET_RISCV64_LP64)
Expand Down Expand Up @@ -94,7 +94,7 @@ os_signal_unmask();
void
os_sigreturn();
#endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0 */

typedef long int __syscall_slong_t;

Expand Down
4 changes: 2 additions & 2 deletions core/shared/platform/darwin/platform_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ typedef pthread_t korp_thread;

#define bh_socket_t int

#if WASM_DISABLE_HW_BOUND_CHECK == 0
#if WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|| defined(BUILD_TARGET_AARCH64) || defined(BUILD_TARGET_RISCV64_LP64D) \
|| defined(BUILD_TARGET_RISCV64_LP64)
Expand Down Expand Up @@ -95,7 +95,7 @@ os_signal_unmask();
void
os_sigreturn();
#endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0 */

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions core/shared/platform/linux/platform_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ typedef pthread_t korp_thread;

#define bh_socket_t int

#if WASM_DISABLE_HW_BOUND_CHECK == 0
#if WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|| defined(BUILD_TARGET_AARCH64) || defined(BUILD_TARGET_RISCV64_LP64D) \
|| defined(BUILD_TARGET_RISCV64_LP64)
Expand Down Expand Up @@ -94,7 +94,7 @@ os_signal_unmask();
void
os_sigreturn();
#endif /* end of BUILD_TARGET_X86_64/AMD_64/AARCH64/RISCV64 */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0 */

#ifdef __cplusplus
}
Expand Down
2 changes: 1 addition & 1 deletion core/shared/platform/vxworks/platform_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ typedef pthread_t korp_thread;

#define os_thread_local_attribute __thread

#if WASM_DISABLE_HW_BOUND_CHECK == 0
#if WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64) \
|| defined(BUILD_TARGET_AARCH64)

Expand Down
4 changes: 2 additions & 2 deletions core/shared/platform/windows/platform_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ os_mem_decommit(void *ptr, size_t size);
#define strncasecmp _strnicmp
#define strcasecmp _stricmp

#if WASM_DISABLE_HW_BOUND_CHECK == 0
#if WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0
#if defined(BUILD_TARGET_X86_64) || defined(BUILD_TARGET_AMD_64)

#include <setjmp.h>
Expand All @@ -102,7 +102,7 @@ os_thread_signal_inited();
#define os_sigreturn() (void)0

#endif /* end of BUILD_TARGET_X86_64/AMD_64 */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK */
#endif /* end of WASM_DISABLE_HW_BOUND_CHECK == 0 && WASM_ENABLE_AOT != 0 */

#ifdef __cplusplus
}
Expand Down