Skip to content

Commit e6d3d25

Browse files
committed
py: update thread_stacksize1.py
Signed-off-by: Koudai Aono <koxudaxi@gmail.com>
1 parent 930d2f3 commit e6d3d25

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

tests/thread/thread_stacksize1.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,27 @@
55
import sys
66
import _thread
77

8+
# Check if we need a larger stack for sanitizer builds
9+
def needs_big_stack():
10+
try:
11+
import os
12+
# Unix/Windows with potential sanitizer builds
13+
if hasattr(os, "name") and os.name in ("posix", "nt"):
14+
# Check for sanitizer environment variables (used in CI)
15+
if hasattr(os, "environ"):
16+
return any(k in os.environ for k in ("UBSAN_OPTIONS", "ASAN_OPTIONS"))
17+
# Emscripten/WebAssembly builds
18+
if hasattr(sys, "platform") and sys.platform == "emscripten":
19+
return True
20+
except:
21+
pass
22+
return False
23+
824
# different implementations have different minimum sizes
925
if sys.implementation.name == "micropython":
10-
sz = 2 * 1024
26+
# Sanitizer builds need larger stack (32KB) due to extra margins
27+
# MCU and normal builds can use smaller stack (2KB)
28+
sz = 32 * 1024 if needs_big_stack() else 2 * 1024
1129
else:
1230
sz = 512 * 1024
1331

0 commit comments

Comments
 (0)