Missing callstack information in @panic for external C functions

Maybe somebody knows a solution:

In a mixed Zig/C code base calling Zig’s @panic() from within a C function (via a Zig callback) produces a complete callstack, but some information is missing for the C locations, e.g.:

/Users/floh/projects/sokol-zig/examples/clear.zig:26:9: 0x100f108b3 in log (clear)
        @panic("PANIC");
        ^
???:?:?: 0x100ddac4b in __sg_log (???)
???:?:?: 0x100e31863 in __sg_validate_end (???)
???:?:?: 0x100df9aef in __sg_validate_begin_pass (???)
???:?:?: 0x100df3bfb in _sg_begin_pass (???)
/Users/floh/projects/sokol-zig/src/sokol/gfx.zig:4778:18: 0x100f10a63 in beginPass (clear)
    sg_begin_pass(&pass);
                 ^
/Users/floh/projects/sokol-zig/examples/clear.zig:45:17: 0x100f1058b in frame (clear)
    sg.beginPass(.{ .action = state.pass_action });
                ^
???:?:?: 0x100dcb393 in __sapp_call_frame (???)
???:?:?: 0x100dbc5cb in __sapp_frame (???)
???:?:?: 0x100dbc1bf in -[_sapp_macos_view drawRect:] (???)

Any ideas if this can be fixed and how? Ideally I would get the same detailed information for the C locations as the Zig locations. Maybe there’s just a handful compiler flags missing for the C code?

E.g. also see the thread here: how to get a callstack from a validation error? · Issue #135 · floooh/sokol-zig · GitHub

Feels related: The Great `std.debug` Refactor by mlugg · Pull Request #25227 · ziglang/zig · GitHub

1 Like