Skip to content

Commit ffed6b8

Browse files
authored
Change shm_open() calling ABI on aarch64 Darwin (#43516)
Beacuse `shm_open()` is a variadic function, if we don't declare it as such, the kernel receives trash as the `permissions` value, which occasionally results in errors when creating shared memory segments. This did not happen on `x86_64` because the calling convention doesn't change so much between variadic and non-vadiadic functions.
1 parent 5819775 commit ffed6b8

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

stdlib/SharedArrays/src/SharedArrays.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,15 @@ function _shm_mmap_array(T, dims, shm_seg_name, mode)
693693
end
694694

695695
shm_unlink(shm_seg_name) = ccall(:shm_unlink, Cint, (Cstring,), shm_seg_name)
696-
shm_open(shm_seg_name, oflags, permissions) = ccall(:shm_open, Cint,
697-
(Cstring, Cint, Base.Cmode_t), shm_seg_name, oflags, permissions)
698-
696+
function shm_open(shm_seg_name, oflags, permissions)
697+
# On macOS, `shm_open()` is a variadic function, so to properly match
698+
# calling ABI, we must declare our arguments as variadic as well.
699+
@static if Sys.isapple()
700+
return ccall(:shm_open, Cint, (Cstring, Cint, Base.Cmode_t...), shm_seg_name, oflags, permissions)
701+
else
702+
return ccall(:shm_open, Cint, (Cstring, Cint, Base.Cmode_t), shm_seg_name, oflags, permissions)
703+
end
704+
end
699705
end # os-test
700706

701707
end # module

0 commit comments

Comments
 (0)