OpenBSD: Obsolete mmap syscall used in libc_openbsd.go
On 2021-12-23, a new syscall for mmap was introduced:
49 STD NOLOCK { void *sys_mmap(void *addr, size_t len, int prot, \
int flags, int fd, off_t pos); }
At the same time, the existing mmap syscall was renamed from sys_mmap to sys_pad_mmap (since it contains a now-obsolete argument for padding).
See sys/kern/syscalls.master:
On 2023-02-11, the original mmap syscall was retired entirely:
https://github.com/openbsd/src/commit/8c7f5cc47d34f1bd83a08278dad544a34184dabf
With the release of OpenBSD 7.3 on 2023-04-10, any go program that uses mmap on OpenBSD will crash with SIGSYS.
Looking at https://gitlab.com/cznic/libc/-/blob/v1.22.3/libc_openbsd.go it seems the argument list was updated correctly, but it's using the wrong syscall number (unix.SYS_MMAP is 197, but it should be 49). I've filed a ticket against go to fix that: https://github.com/golang/go/issues/59661
Attached is a test program and the output from kdump. The failure snippet in question is:
1487 mmap-modernc CALL (via syscall) #197 (obsolete pad_mmap)()
1487 mmap-modernc PSIG SIGSYS caught handler=0x4611a0 mask=0<>
1487 mmap-modernc RET #197 (obsolete pad_mmap) -1 errno 78 Function not implemented
FWIW, the unix.Mmap function from golang.org/x/sys/unix works as expected.