authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-05-12 19:03:04-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2025-05-17 02:08:41-04:00
log4adb7eca6ab2148026a9d2e00379cedfc2038a0d
treeb5e6bb6bb2b392d152fda3396acd02c1924e68d5
parent025611629f95cda21ff93a517406ea8387ad9cfb

debug: correctly detect missing entries in `.eh_frame_hdr`


2 files changed, 4 insertions(+), 2 deletions(-)

lib/std/debug/Dwarf.zig+3-1
......@@ -402,7 +402,7 @@ pub const ExceptionFrameHeader = struct {
402402 }
403403 }
404404
405 if (len == 0) return bad();
405 if (len == 0) return missing();
406406 fbr.pos = left * entry_size;
407407
408408 // Read past the pc_begin field of the entry
......@@ -460,6 +460,8 @@ pub const ExceptionFrameHeader = struct {
460460 @sizeOf(usize),
461461 native_endian,
462462 );
463
464 if (pc < fde.pc_begin or pc >= fde.pc_begin + fde.pc_range) return missing();
463465 }
464466};
465467
lib/std/debug/SelfInfo.zig+1-1
......@@ -1633,7 +1633,7 @@ pub fn unwindFrameDwarf(
16331633 &cie,
16341634 &fde,
16351635 ) catch |err| switch (err) {
1636 error.InvalidDebugInfo => {
1636 error.MissingDebugInfo => {
16371637 // `.eh_frame_hdr` appears to be incomplete, so go ahead and populate `cie_map`
16381638 // and `fde_list`, and fall back to the binary search logic below.
16391639 try di.scanCieFdeInfo(allocator, base_address);