Skip to content

Commit 8fa4431

Browse files
yamtvickiegpt
authored andcommitted
core/config.h: Bump the default WASM_STACK_GUARD_SIZE (bytecodealliance#3344)
The old value (1KB) doesn't seem sufficient for many cases. I suspect that the new value is still not sufficient for some cases. But it's far safer than the old value. Consider if the classic interpreter loop (2600 bytes) calls host snprintf. (2000 bytes) Fixes: bytecodealliance#3314 Signed-off-by: victoryang00 <[email protected]>
1 parent 9860256 commit 8fa4431

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

core/config.h

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,26 @@
491491
/* UVWASI requires larger native stack */
492492
#define WASM_STACK_GUARD_SIZE (4096 * 6)
493493
#else
494-
#define WASM_STACK_GUARD_SIZE (1024)
494+
/*
495+
* Use a larger default for platforms like macOS/Linux.
496+
*
497+
* For example, wasm_interp_call_func_bytecode + wasm_runtime_set_exception
498+
* would consume >4KB stack on x86-64 macOS.
499+
*
500+
* Although product-mini/platforms/nuttx always overrides
501+
* WASM_STACK_GUARD_SIZE, exclude NuttX here just in case.
502+
*/
503+
#if defined(__APPLE__) || (defined(__unix__) && !defined(__NuttX__))
504+
#define WASM_STACK_GUARD_SIZE (1024 * 5)
505+
#else
506+
/*
507+
* Otherwise, assume very small requirement for now.
508+
*
509+
* Embedders for very small devices likely fine-tune WASM_STACK_GUARD_SIZE
510+
* for their specific applications anyway.
511+
*/
512+
#define WASM_STACK_GUARD_SIZE 1024
513+
#endif
495514
#endif
496515
#endif
497516

0 commit comments

Comments
 (0)