Skip to content

Better "Stack Overflow" error message #16055

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

Closed
pprettysimpple opened this issue Jun 15, 2023 · 2 comments
Closed

Better "Stack Overflow" error message #16055

pprettysimpple opened this issue Jun 15, 2023 · 2 comments
Labels
error message This issue points out an error message that is unhelpful and should be improved.

Comments

@pprettysimpple
Copy link

Zig Version

0.11.0-dev.3395+1e7dcaa3a

Steps to Reproduce and Observed Output

Currently, overflowing the default stack size causes segfault of compiled program, but it would be nice to have some error message if possible. Maybe only in debug-mod or so.
While debugging, it is hard to know if that was "SO" or something else in code.
There is small example for causing this:

pub fn foo(deep: u32) u32 {
    if (deep == 0) {
        return 0;
    }
    return foo(deep - 1) + 1;
}

pub fn main() void {
    _ = foo(1024 * 1014 * 30);
}

Expected Output

Some error message that it was exactly stack-overflow and not other issues in code

@pprettysimpple pprettysimpple added the error message This issue points out an error message that is unhelpful and should be improved. label Jun 15, 2023
@pprettysimpple
Copy link
Author

for example, this code in Rust will cause a readable error message
demo.rs

fn foo(val: usize) -> usize {
    if val == 0 {
        return 0;
    }

    1 + foo(val - 1)
}

pub fn main() {
    foo(30 * 1024 * 1024);
}

output:

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
Aborted (core dumped)

@nektro
Copy link
Contributor

nektro commented Jun 15, 2023

duplicate #7371

@Vexu Vexu closed this as completed Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error message This issue points out an error message that is unhelpful and should be improved.
Projects
None yet
Development

No branches or pull requests

3 participants