aboutsummaryrefslogtreecommitdiff
path: root/src/codegen
diff options
context:
space:
mode:
authortaylor.fish <contact@taylor.fish>2025-06-21 21:47:58 -0700
committertaylor.fish <contact@taylor.fish>2025-06-21 21:47:58 -0700
commit79807468e747bac056cfea4340065e49a5d97120 (patch)
tree7e5e328c249d73527b425c3c45df20c542c876d3 /src/codegen
parent75d0ec9c0476da61c6f32b3d386d8844faaeb1c5 (diff)
downloadzig-79807468e747bac056cfea4340065e49a5d97120.tar.gz
zig-79807468e747bac056cfea4340065e49a5d97120.zip
Fix illegal behavior from syscalls on powerpc64le
On powerpc64le Linux, the registers used for passing syscall parameters (r4-r8, as well as r0 for the syscall number) are volatile, or caller-saved. However, Zig's syscall wrappers for this architecture do not include all such registers in the list of clobbers, leading the compiler to assume these registers will maintain their values after the syscall completes. In practice, this resulted in a segfault when allocating memory with `std.heap.SmpAllocator`, which calls `std.os.linux.sched_getaffinity`. The third parameter to `sched_getaffinity` is a pointer to a `cpu_set_t` and is stored in register r5. After the syscall, the code attempts to access data in the `cpu_set_t`, but because the compiler doesn't realize the value of r5 may have changed, it uses r5 as the memory address, which in practice resulted in a memory access at address 0x8. This commit adds all volatile registers to the list of clobbers.
Diffstat (limited to 'src/codegen')
0 files changed, 0 insertions, 0 deletions