Feature/development environment setup cd8c#15
Merged
Conversation
- 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>
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>
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>
omiq
added a commit
that referenced
this pull request
Apr 15, 2026
* 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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.