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

runtime stack traces no longer working in release mode #15546

Open
nektro opened this issue May 2, 2023 · 4 comments
Open

runtime stack traces no longer working in release mode #15546

nektro opened this issue May 2, 2023 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@nektro
Copy link
Contributor

nektro commented May 2, 2023

Zig Version

0.11.0-dev.2928+440b3df70

Steps to Reproduce and Observed Behavior

pub fn main() !void {
    try foo();
}

fn foo() !void {
    try bar();
}

fn bar() !void {
    try bzq();
}

fn bzq() !void {
    @panic("goo");
}
[meghan@nixos]$ zig2 run test.zig -O ReleaseSafe
thread 586207 panic: goo
Aborted (core dumped)
[meghan@nixos]$ zig2 run test.zig -O ReleaseSafe -fno-strip
thread 586281 panic: goo
Aborted (core dumped)

Expected Behavior

[meghan@nixos]$ zig2 run test.zig -O Debug
thread 586445 panic: goo
/run/media/meghan/dev/test.zig:14:5: 0x20b1c5 in bzq (test)
    @panic("goo");
    ^
/run/media/meghan/dev/test.zig:10:12: 0x20b1d8 in bar (test)
    try bzq();
           ^
/run/media/meghan/dev/test.zig:6:12: 0x20b1e8 in foo (test)
    try bar();
           ^
/run/media/meghan/dev/test.zig:2:12: 0x20b1f8 in main (test)
    try foo();
           ^
/home/meghan/src/zig/lib/std/start.zig:609:37: 0x20acc4 in posixCallMainAndExit (test)
            const result = root.main() catch |err| {
                                    ^
/home/meghan/src/zig/lib/std/start.zig:368:5: 0x20a751 in _start (test)
    @call(.never_inline, posixCallMainAndExit, .{});
    ^
Aborted (core dumped)
@nektro nektro added the bug Observed behavior contradicts documented or intended behavior label May 2, 2023
@andrewrk andrewrk added regression It worked in a previous version of Zig, but stopped working. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library. labels Jun 21, 2023
@andrewrk andrewrk added this to the 0.11.1 milestone Jun 21, 2023
@andrewrk andrewrk removed the regression It worked in a previous version of Zig, but stopped working. label Jun 21, 2023
@andrewrk andrewrk modified the milestones: 0.11.1, 0.12.0 Jun 21, 2023
@ifreund
Copy link
Member

ifreund commented Jun 21, 2023

Looks like this will be fixed for ELF at least by #15823

In the meantime, passing -fno-omit-frame-pointer can give the std.debug stacktrace printing code a hand in release builds.

@nektro
Copy link
Contributor Author

nektro commented Oct 16, 2023

this specific example was likely fixed by #15823 output is now good on 0.11.0

thread 2960263 panic: goo
/run/media/meghan/bcfe99da-edd3-45c5-8abf-14c763507a7f/dev/waffle/test.zig:26:5: 0x20be01 in main (test)
    @panic("goo");
    ^
/home/meghan/.local/share/zig/lib/std/start.zig:574:37: 0x20bdd4 in posixCallMainAndExit (test)
            const result = root.main() catch |err| {
                                    ^
/home/meghan/.local/share/zig/lib/std/start.zig:243:5: 0x20bcb1 in _start (test)
    asm volatile (switch (native_arch) {
    ^
???:?:?: 0x0 in ??? (???)
Aborted (core dumped)

edit: realized its missing all the inner try frames

@nektro nektro closed this as completed Oct 16, 2023
@nektro nektro reopened this Oct 16, 2023
@nektro
Copy link
Contributor Author

nektro commented Nov 10, 2023

result when inspecting a trace in waffle

[meghan@nixos:~]$ sudo cat /run/media/meghan/waffledata/git2/data/log-mOJphH
panic: reached unreachable code
Unwind error at address `exe:0x41850a` (error.InvalidDebugInfo), trace may be incomplete

???:?:?: 0x3cef17 in ??? (exe)
???:?:?: 0x411113 in ??? (exe)
???:?:?: 0x411e52 in ??? (exe)
???:?:?: 0x4112ba in ??? (exe)
???:?:?: 0x82fb5a in ??? (exe)

@linusg
Copy link
Contributor

linusg commented Nov 25, 2023

I get a similar InvalidDebugInfo error in kiesel when building with -Denable-intl=true, i.e. linking ICU4X's libicu_capi_staticlib.a - works fine with false. May be related to #10354 and #12046.

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 contributor friendly This issue is limited in scope and/or knowledge of Zig internals. standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

4 participants