Loading
Commits on Source 1
-
cznic authored
NetBSD's mmap(2) syscall is mmap(void *addr, size_t len, int prot, int flags, int fd, long PAD, off_t pos) i.e. there is a `long PAD` argument before `off_t pos`. Xmmap used unix.Syscall6(SYS_MMAP, addr, len, prot, flags, fd, offset): that places the offset in the PAD slot and leaves pos as stack garbage, so the kernel maps at a garbage file offset and returns an unaligned / unbacked pointer that faults on first access. This deterministically crashed the SQLite WAL-index shared memory (walIndexTryHdr memcpy, SIGBUS) under concurrent WAL access. Pass the offset as the 7th argument via Syscall9 with a 0 PAD, matching golang.org/x/sys/unix's own netbsd mmap wrapper (zsyscall_netbsd_amd64.go). This is correct for all addr values (the previous addr!=0 path was equally affected). Fixes modernc.org/sqlite#246 on netbsd/amd64. Co-Authored-By:Claude Opus 4.8 <noreply@anthropic.com>