You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs(AGENTS.md): add Raylib and emsdk Cloud Agent setup notes
- Document Raylib installation (from source, gcc/g++ cmake workaround)
- Document emsdk location (~/.bashrc sourcing) and WASM build/test targets
- Note that basic-gfx cannot run headlessly in Cloud Agent VMs
- Add Playwright WASM test commands reference
Co-authored-by: Chris Garrett <chris@chrisg.com>
* Add multi-dimensional array WASM freeze reproduction test
Adds a minimal BASIC program that triggers a WASM stack overflow
in the canvas (GFX_VIDEO) build due to eval_factor() allocating
struct value args[MAX_UDF_PARAMS] (~65KB) on the stack, exceeding
the default Emscripten STACK_SIZE of 64KB.
Root cause: eval_factor() speculatively parses A(I,0) as a potential
UDF call, allocating a 65KB args array. The 2D array index evaluation
recursively calls eval_factor, compounding stack usage beyond 64KB.
Fix needed: increase STACK_SIZE in Makefile WASM targets and/or
heap-allocate args in eval_factor().
Co-authored-by: Chris Garrett <chris@chrisg.com>
* fix(wasm): heap-allocate UDF args to prevent stack overflow on 2D arrays
Root cause: eval_factor() and execute_statement() declared
struct value args[MAX_UDF_PARAMS] on the stack — 16 × 4108 = ~65KB,
which exceeds Emscripten's default 64KB stack. When evaluating 2D
array expressions like A(I,J), recursive eval_factor calls compounded
the overflow, causing the WASM interpreter to freeze.
Fix (defense in depth):
- Heap-allocate args via calloc() in both eval_factor() and
execute_statement(), freeing on all exit paths
- Increase WASM STACK_SIZE from 64KB to 512KB in all three Makefile
targets (basic-wasm, basic-wasm-modular, basic-wasm-canvas)
Added tests/dim2d_wasm_test.bas regression test.
Co-authored-by: Chris Garrett <chris@chrisg.com>
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
0 commit comments