Commits on Source 1

  • cznic's avatar
    libc_netbsd.go: fix Xmmap for the NetBSD mmap(2) PAD ABI · 533f38d8
    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: default avatarClaude Opus 4.8 <noreply@anthropic.com>
    533f38d8
Loading
Loading