authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-14 23:07:22+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-10-15 13:59:17+02:00
log62a8cfd5fed1380331b10d20fbb7b08f206cf541
treef3dd6af5e91291d0a410888d20afdb56d6dd202e
parenta36dab2f90020c5544fddf68520c2057edc2ec00
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

std.debug: fix an invalid read in StackIterator.next()

We're overwriting the memory that unwind_context sits in, so we need to do the getFp() call earlier.

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

lib/std/debug.zig+2-1
...@@ -925,7 +925,8 @@ const StackIterator = union(enum) {...@@ -925,7 +925,8 @@ const StackIterator = union(enum) {
925 const di_gpa = getDebugInfoAllocator();925 const di_gpa = getDebugInfoAllocator();
926 const ret_addr = di.unwindFrame(di_gpa, unwind_context) catch |err| {926 const ret_addr = di.unwindFrame(di_gpa, unwind_context) catch |err| {
927 const pc = unwind_context.pc;927 const pc = unwind_context.pc;
928 it.* = .{ .fp = unwind_context.getFp() };928 const fp = unwind_context.getFp();
929 it.* = .{ .fp = fp };
929 return .{ .switch_to_fp = .{930 return .{ .switch_to_fp = .{
930 .address = pc,931 .address = pc,
931 .err = err,932 .err = err,