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

stage2: Inline recursive functions can overflow the compiler's stack #12973

Closed
topolarity opened this issue Sep 26, 2022 · 0 comments
Closed
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@topolarity
Copy link
Contributor

Zig Version

0.10.0-dev.4166+cae76d829

Steps to Reproduce

test {
    @setEvalBranchQuota(100_000);
    const y = sum_to(10_000);
    _ = y;
}

inline fn sum_to(n: usize) usize {
    if (n <= 2) return n;
    return n + sum_to(n - 1);
}

Expected Behavior

The compiler should not experience stack overflow.

Actual Behavior

$ gdb --args ./build/stage3/bin/zig test test.zig
...
Thread 1 "zig" received signal SIGSEGV, Segmentation fault.
0x0000000009cc7394 in __zig_probe_stack ()
@topolarity topolarity added the bug Observed behavior contradicts documented or intended behavior label Sep 26, 2022
@topolarity topolarity changed the title stage2: Inline recursive function instantiations can overflow the compiler's stack stage2: Inline recursive functions can overflow the compiler's stack Sep 26, 2022
topolarity added a commit to topolarity/zig that referenced this issue Sep 26, 2022
@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Sep 26, 2022
@Vexu Vexu added this to the 0.10.0 milestone Sep 26, 2022
topolarity added a commit to topolarity/zig that referenced this issue Sep 26, 2022
topolarity added a commit to topolarity/zig that referenced this issue Sep 26, 2022
topolarity added a commit to topolarity/zig that referenced this issue Sep 27, 2022
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Oct 12, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 15, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 15, 2022
topolarity added a commit to topolarity/zig that referenced this issue Oct 15, 2022
Vexu pushed a commit to Vexu/zig that referenced this issue Oct 20, 2022
Vexu added a commit to Vexu/zig that referenced this issue Oct 20, 2022
Don't forget to add these back when solving ziglang#12973
Vexu added a commit to Vexu/zig that referenced this issue Oct 20, 2022
Don't forget to add these back when solving ziglang#12973
Vexu added a commit to Vexu/zig that referenced this issue Oct 20, 2022
Don't forget to add these back when solving ziglang#12973
topolarity added a commit to topolarity/zig that referenced this issue Oct 20, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 19, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 20, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 20, 2022
Vexu added a commit to Vexu/zig that referenced this issue Dec 26, 2022
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 2024
Don't forget to add these back when solving ziglang#12973
TUSF pushed a commit to TUSF/zig that referenced this issue May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

No branches or pull requests

3 participants