-
-
Notifications
You must be signed in to change notification settings - Fork 267
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
wasm: Add new default lld switches to protect from stackoverflow overwriting global memory #3882
Conversation
It's failing with:
So most like you have to use a different syntax to set these options for WASM. Also, I think it would be cleaner if you set the options in the config file here: Lines 37 to 40 in 5a28329
|
That was my initial thought, but i wasn't sure, i used these options in my dub file: "lflags-ldc": [
"-z","stack-size=1048576",
"--stack-first",
"-allow-undefined"
], I'm not sure how to translate to use directly with LDC |
|
Indeed. The proposed change in the CMakeFile will only help if LDC is built with LLD built-in. The case where an external LLD is used for linking, would still need manual adding of these flags. If you add the flags to Edit: or you add the flags unconditionally to the variable in CMakeFile. Perhaps better, because there are multiple ldc2.conf files that need adjustment (will be automatic when you change the CMakeFile variable). |
Yep, exactly. [And prefixed with |
it needs approval to trigger builds |
Yeah that's annoying, and IIRC, requires a new approval after each push. - Wrt. making LDC specify these flags without integrated LLD too, please just move the new lines right before the |
done! |
Sorry about being so pedantic, but the CMake scripts are messy enough already. ;) |
Sorry about that! done! |
Thanks! |
I was stuck on trying to fix a bug on my code, whenever i was manipulating around large stucts, it'd change global data
I first thought of a memory corruption somewhere, but it turns out it was a stackoverflow issue!
Increasing the default stack (from 64kb) to 1mb fixed the issue... temporarily! as i was playing with more data, i hit the issue again.. so i looked around and found this PR on the zig repo: ziglang/zig#4496
Tada! now instead of overwritting my global memory, it throws a runtime error! that's better! i can now debug the issue properly!
Let's save people days of headache and make these options the default!
Zig/Rust also bumped the default stack size to 1mb (emscripten has a stack size of 5mb)