authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-12 21:45:26-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-20 22:58:16-04:00
log9549b4acf67ec7dfcebf5373c11cdc7af3d41aae
tree21be3422b4beaad769b9eab11992f10fb2327fbc
parent06bf2e048b24dcba28bcb7b00236b3cdb2504cc4

debug: fixup an inconsistency in the getcontext implementation on aarch64-macos


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

lib/std/debug.zig+9-1
......@@ -190,7 +190,15 @@ pub inline fn getContext(context: *ThreadContext) bool {
190190 }
191191
192192 const result = have_getcontext and os.system.getcontext(context) == 0;
193 if (native_os == .macos) assert(context.mcsize == @sizeOf(std.c.mcontext_t));
193 if (native_os == .macos) {
194 assert(context.mcsize == @sizeOf(std.c.mcontext_t));
195
196 // On aarch64-macos, the system getcontext doesn't write anything into the pc
197 // register slot, it only writes lr. This makes the context consistent with
198 // other aarch64 getcontext implementations which write the current lr
199 // (where getcontext will return to) into both the lr and pc slot of the context.
200 if (native_arch == .aarch64) context.mcontext.ss.pc = context.mcontext.ss.lr;
201 }
194202
195203 return result;
196204}