Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add SAFE_HEAP=1 and STACK_OVERFLOW_CHECK=1 for Emscripten Debug builds #56

Conversation

silbinarywolf
Copy link
Contributor

I've found adding these has helped me debug and actually understand why my Emscripten application was randomly crashing.

For example, I was loading an image with the Zigimg package and the errors in my Chrome/Firefox DevTools would just say segmentation fault without pointing at a clear reason for the crash.

With -sSTACK_OVERFLOW_CHECK=1, I was able to instead get the following message and realize that I needed to bump my stack size.

index.js:9219 Stack overflow detected.  You can try increasing -sSTACK_SIZE (currently set to 65536)

@floooh
Copy link
Owner

floooh commented Feb 19, 2024

Thanks for the PR! I'm not sure what performance implications those have (e.g. even though it's only in debug, more complex programs may become 'too slow' with those settings).

If it becomes too slow we might want to make those settings configurable via EmLinkOptions, but I think for now at least it makes sense to merge it as is.

The current Zig nightly has pretty severe breakge unfortunately (installing packages from github doesn't work - that's why the CI fails, and the wasm32-emscripten target seems to be broken, I get an error root struct of file 'os.wasi' has no member named 'E' (I'll merge the PR anyways, since the change is trivial).

@floooh floooh merged commit 4b046bc into floooh:master Feb 19, 2024
0 of 3 checks passed
@silbinarywolf silbinarywolf deleted the add-extra-memory-safety-checks-for-emscripten branch February 19, 2024 22:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants