aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorJakub Konka <kubkon@jakubkonka.com>2022-12-11 08:49:20 +0100
committerJakub Konka <kubkon@jakubkonka.com>2022-12-11 13:46:57 +0100
commit0214d2d745c08e4f0a3fbc80cb8393ad295b343c (patch)
tree08d5d152b72eea69001287892ff31af7770321d3 /lib/std/debug.zig
parent9bcfe55b5c892ed584a8cc4cb60a4df3a1b8bffc (diff)
downloadzig-0214d2d745c08e4f0a3fbc80cb8393ad295b343c.tar.gz
zig-0214d2d745c08e4f0a3fbc80cb8393ad295b343c.zip
Remove incorrect assertion in readMachODebugInfo panicking during panic
This fixes a class of bugs on macOS where a segfault happening in a loaded dylib with no debug info would cause a panic in the panic handler instead of simply noting that the dylib has no valid debug info via `error.MissingDebugInfo`. An example could be code linking some system dylib and causing some routine to segfault on say invalid pointer value, which should normally cause Zig to print an incomplete stack trace anchored at the currently loaded image and backtrace all the way back to the Zig binary with valid debug info. Currently, in a situation like this we would trigger a panic within a panic.
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 90ceff3df1..545f205634 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -1110,7 +1110,12 @@ fn readMachODebugInfo(allocator: mem.Allocator, macho_file: File) !ModuleDebugIn
else => {},
}
}
- assert(state == .oso_close);
+
+ switch (state) {
+ .init => return error.MissingDebugInfo,
+ .oso_close => {},
+ else => return error.InvalidDebugInfo,
+ }
const symbols = try allocator.realloc(symbols_buf, symbol_index);