-
-
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
design flaw: self-hosted compiler uses its own stack for comptime function calls, resulting in stack overflow when the host system does not provide a large enough stack #13724
Comments
once async is implemented what if you have a separate stack for calling comptime functions and then use |
Duplicate of #12973 |
See tracking issue ziglang#13724
Not a duplicate since this is comptime and the other is an inline call. |
Here's another simple reproduction: fn rec(comptime i: comptime_int) comptime_int {
return if (i == 1e3) i else rec(i + 1);
}
test "comptime stack overflow" {
// @setEvalBranchQuota(100_000);
_ = rec(0);
} I'd at least expect an error message indicating that there was a stack overflow (however that can be accomplished). Currently there's no output. |
keywords to prevent duplicates: recursive, comptime, stack overflow, segfault |
zig version:
0.11.0-dev.407+34fa6a1e0
Ideally this code would produce a compile error: comptime execution exceeded 1000 branches. However,
This causes a segfault in many cases due to stack overflow. It cannot be solved by asking for more stack space for these reasons:
@setEvalBranchQuota
.Until this is fixed I am unfortunately going to have to edit the corresponding code snippet from the language reference:
zig/doc/langref.html.in
Lines 7032 to 7052 in a943422
The text was updated successfully, but these errors were encountered: