Skip to content

Commit a06db28

Browse files
committed
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 parent c23a5cc commit a06db28

File tree

1 file changed

+5
-15
lines changed

1 file changed

+5
-15
lines changed

lib/std/debug/SelfInfo/MachO.zig

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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)).*;

0 commit comments

Comments
 (0)