-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Regression: Stack overflow when initializing large struct with initializer syntax. #17289
Comments
I also had to add some workarounds for a new regression in the zig compiler: ziglang/zig#17289
does the problem still occur if you change it to |
Thanks @xdBronch that's the perfect solution. |
Yeah, sorry, this is #17194. This is one unfortunate side effect of that proposal - I ran into it myself in the standard library tests, where I had to up the WASI stack size. #1639 would be desirable here. In general, |
Why is it worth increasing the risk of stack overflow over what used to be a stylistic choice? In Bun's codebase, we often use the explicit form |
Please read #17194 to understand the motivation. This change was not without reason: it simplifies the language and compiler design, and fixes several miscompilations. It's not unlikely that #5038 is eventually accepted, in which case I'm happy to personally collaborate with downstream (cc @Techatrix, @SuperAuguste) if this is an area I can potentially help to improve in the short-term. In addition, with the active work on incremental compilation, we'll hopefully be able to start hacking away at #615 soon to improve the ZLS experience across the board. |
Zig Version
0.12.0-dev.596+2adb932ad (worked in 0.12.0-dev.494+a8d2ed806)
Steps to Reproduce and Observed Behavior
Output:
Expected Behavior
It should not take excessive amounts of stack memory to initialize big structs using the initializer syntax.
Now you might just think that I am insane for using such excessively big structs and maybe I am, but I like to avoid unnecessary indirection where possible, so when I know the size of an array upfront, I just put it into the struct directly. In this case for example it was a bunch of 2¹⁶=65536 sized arrays of 3d vectors.
The workaround here would be to manually initialize the required fields, but that is tedious and error prone, since I need to manually take care about all the default field values.
The text was updated successfully, but these errors were encountered: