File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ // Generates Python files that explore stack size limits
2+ // We hit an asyncify limit here:
3+ // https://github.com/microbit-foundation/micropython-microbit-v2-simulator/issues/105
4+
5+ // At 169 we get pystack exhausted
6+ // With lower powers of 2 for ASYNCIFY_STACK_SIZE we get an asyncify error
7+ // before we exhaust the stack.
8+ const limit = 168 ;
9+
10+ let code = `
11+ def outer():
12+ i = 0
13+ while True:
14+ print(i)
15+ i += 1
16+ f${ limit - 1 } ()
17+
18+ def f0():
19+ pass
20+
21+ ` ;
22+
23+ for ( let i = limit - 1 ; i > 0 ; -- i ) {
24+ code += `
25+ def f${ i } ():
26+ f${ i - 1 } ()
27+
28+ ` ;
29+ }
30+
31+ code += "outer()" ;
32+
33+ console . log ( code ) ;
Original file line number Diff line number Diff line change @@ -44,6 +44,8 @@ COPT += -O3 -DNDEBUG
4444endif
4545
4646JSFLAGS += -s ASYNCIFY
47+ # We can hit lower values due to user stack use. See stack-size.mjs.
48+ JSFLAGS += -s ASYNCIFY_STACK_SIZE=262144
4749JSFLAGS += -s EXIT_RUNTIME
4850JSFLAGS += -s MODULARIZE=1
4951JSFLAGS += -s EXPORT_NAME=createModule
You can’t perform that action at this time.
0 commit comments