memset crash
While running sqlite tests:
...
Time: ovfl.test 110 ms
unexpected fault address 0x7fe738600000
fatal error: fault
[signal SIGSEGV: segmentation violation code=0x1 addr=0x7fe738600000 pc=0x4d910c]
goroutine 1 [running, locked to thread]:
runtime.throw(0xb18d7f, 0x5)
/home/jnml/src/go.googlesource.com/go/goroot/src/runtime/panic.go:1116 +0x72 fp=0xc000715300 sp=0xc0007152d0 pc=0x433e92
runtime.sigpanic()
/home/jnml/src/go.googlesource.com/go/goroot/src/runtime/signal_unix.go:749 +0x405 fp=0xc000715330 sp=0xc000715300 pc=0x449a05
modernc.org/libc.Xmemset(0xc0001220f0, 0x7fe7385ffffc, 0x0, 0x4, 0x7fe7385fffe8)
/home/jnml/src/modernc.org/libc/libc.go:676 +0x6c fp=0xc000715350 sp=0xc000715330 pc=0x4d910c
modernc.org/sqlite/lib.Xsqlite3ParseUri(0xc0001220f0, 0x0, 0x7fe737d002f8, 0x7fe737d003c8, 0x7fe737bb7028, 0x7fe737d003d0, 0x7fe737d003d8, 0xc000000000)
/home/jnml/src/modernc.org/sqlite/lib/sqlite_linux_amd64.go:146173 +0xef7 fp=0xc000715470 sp=0xc000715350 pc=0x646557
This line
modernc.org/libc.Xmemset(0xc0001220f0, 0x7fe7385ffffc, 0x0, 0x4, 0x7fe7385fffe8)
says that memset was called with s=0x7fe7385ffffc, c=0x0 and n=0x4. The fault address is the address immediatelly following the 4 byte block that memset has to fill. We are not allowed to touch that memory, it may be an unallocated virtual address.
The line that crashes is
b8 := (*RawMem64)(unsafe.Pointer(s + bytesBeforeAllignment))[: n/8 : n/8]
It seems that this line and the following
for i := range b8 {
b8[i] = i64
}
have to be guarded by something like if n >= 8 {
condition.