authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-07 09:33:42+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-07 17:13:58+02:00
loga06db282c75dba5fa0a2859088840a24d04c7c7f
treef92d9282eda853334727f79c96ea2fe3df92d991
parentc23a5ccd19f08d485820a1d5deea04a6e10fe7bb
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug.SelfInfo.MachO: don't restore vector registers during unwinding

We know that these are unsupported and irrelevant for unwinding, so don't fail the unwind attempt trying to read/write them for no ultimate purpose.

1 files changed, 5 insertions(+), 15 deletions(-)

lib/std/debug/SelfInfo/MachO.zig+5-15
......@@ -401,21 +401,11 @@ fn unwindFrameInner(si: *SelfInfo, gpa: Allocator, context: *UnwindContext) !usi
401401 }
402402 }
403403
404 inline for (@typeInfo(@TypeOf(frame.d_reg_pairs)).@"struct".fields, 0..) |field, i| {
405 if (@field(frame.d_reg_pairs, field.name) != 0) {
406 // Only the lower half of the 128-bit V registers are restored during unwinding
407 {
408 const dest: *align(1) usize = @ptrCast(try context.cpu_state.dwarfRegisterBytes(64 + 8 + i));
409 dest.* = @as(*const usize, @ptrFromInt(reg_addr)).*;
410 }
411 reg_addr += @sizeOf(usize);
412 {
413 const dest: *align(1) usize = @ptrCast(try context.cpu_state.dwarfRegisterBytes(64 + 9 + i));
414 dest.* = @as(*const usize, @ptrFromInt(reg_addr)).*;
415 }
416 reg_addr += @sizeOf(usize);
417 }
418 }
404 // We intentionally skip restoring `frame.d_reg_pairs`; we know we don't support
405 // vector registers in the AArch64 `cpu_context` anyway, so there's no reason to
406 // fail a legitimate unwind just because we're asked to restore the registers here.
407 // If some weird/broken unwind info tells us to read them later, we will fail then.
408 reg_addr += 16 * @as(usize, @popCount(@as(u4, @bitCast(frame.d_reg_pairs))));
419409
420410 const new_ip = @as(*const usize, @ptrFromInt(ip_ptr)).*;
421411 const new_fp = @as(*const usize, @ptrFromInt(fp)).*;