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 {...@@ -402,7 +402,7 @@ pub const ExceptionFrameHeader = struct {
402 }402 }
403 }403 }
404404
405 if (len == 0) return bad();405 if (len == 0) return missing();
406 fbr.pos = left * entry_size;406 fbr.pos = left * entry_size;
407407
408 // Read past the pc_begin field of the entry408 // Read past the pc_begin field of the entry
...@@ -460,6 +460,8 @@ pub const ExceptionFrameHeader = struct {...@@ -460,6 +460,8 @@ pub const ExceptionFrameHeader = struct {
460 @sizeOf(usize),460 @sizeOf(usize),
461 native_endian,461 native_endian,
462 );462 );
463
464 if (pc < fde.pc_begin or pc >= fde.pc_begin + fde.pc_range) return missing();
463 }465 }
464};466};
465467
lib/std/debug/SelfInfo.zig+1-1
...@@ -1633,7 +1633,7 @@ pub fn unwindFrameDwarf(...@@ -1633,7 +1633,7 @@ pub fn unwindFrameDwarf(
1633 &cie,1633 &cie,
1634 &fde,1634 &fde,
1635 ) catch |err| switch (err) {1635 ) catch |err| switch (err) {
1636 error.InvalidDebugInfo => {1636 error.MissingDebugInfo => {
1637 // `.eh_frame_hdr` appears to be incomplete, so go ahead and populate `cie_map`1637 // `.eh_frame_hdr` appears to be incomplete, so go ahead and populate `cie_map`
1638 // and `fde_list`, and fall back to the binary search logic below.1638 // and `fde_list`, and fall back to the binary search logic below.
1639 try di.scanCieFdeInfo(allocator, base_address);1639 try di.scanCieFdeInfo(allocator, base_address);