Skip to content

Commit 72cc07d

Browse files
authored
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
1 parent 62582fb commit 72cc07d

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
@@ -486,7 +486,26 @@
486486
/* UVWASI requires larger native stack */
487487
#define WASM_STACK_GUARD_SIZE (4096 * 6)
488488
#else
489-
#define WASM_STACK_GUARD_SIZE (1024)
489+
/*
490+
* Use a larger default for platforms like macOS/Linux.
491+
*
492+
* For example, wasm_interp_call_func_bytecode + wasm_runtime_set_exception
493+
* would consume >4KB stack on x86-64 macOS.
494+
*
495+
* Although product-mini/platforms/nuttx always overrides
496+
* WASM_STACK_GUARD_SIZE, exclude NuttX here just in case.
497+
*/
498+
#if defined(__APPLE__) || (defined(__unix__) && !defined(__NuttX__))
499+
#define WASM_STACK_GUARD_SIZE (1024 * 5)
500+
#else
501+
/*
502+
* Otherwise, assume very small requirement for now.
503+
*
504+
* Embedders for very small devices likely fine-tune WASM_STACK_GUARD_SIZE
505+
* for their specific applications anyway.
506+
*/
507+
#define WASM_STACK_GUARD_SIZE 1024
508+
#endif
490509
#endif
491510
#endif
492511

0 commit comments

Comments
 (0)