Open XuHuaiyu opened 2 years ago
Same here with go 1.18
fatal error: checkptr: pointer arithmetic result points to invalid allocation
goroutine 619 [running]:
runtime.throw({0x2bf0282?, 0x4a08f9?})
/usr/local/go/src/runtime/panic.go:992 +0x71 fp=0xc001876b68 sp=0xc001876b38 pc=0x469d71
runtime.checkptrArithmetic(0x0?, {0x0, 0x0, 0x0?})
/usr/local/go/src/runtime/checkptr.go:69 +0xaa fp=0xc001876b98 sp=0xc001876b68 pc=0x43a40a
github.com/spaolacci/murmur3.Sum32WithSeed({0xc001876cc0, 0x11, 0x20}, 0x0)
/home/francesco/go/pkg/mod/github.com/spaolacci/murmur3@v1.1.0/murmur32.go:129 +0x90 fp=0xc001876c00 sp=0xc001876b98 pc=0x23d7b90
github.com/spaolacci/murmur3.Sum32(...)
/home/francesco/go/pkg/mod/github.com/spaolacci/murmur3@v1.1.0/murmur32.go:111
github.com/rudderlabs/rudder-server/services/pgnotifier.(*PgNotifierT).RunMaintenanceWorker(0x49337c0, {0x39f0c10, 0xc00095e280})
/home/francesco/Code/rudderstack/rudder-server/services/pgnotifier/pgnotifier.go:427 +0x8c fp=0xc001876e60 sp=0xc001876c00 pc=0x23dd42c
Here's the offending line:
https://github.com/spaolacci/murmur3/blob/f09979ecbc725b9e6d41a297405f65e7e8804acc/murmur32.go#L129
My understanding of the issue: the sanitizer expects that an unsafe.Pointer
should be valid for a full word-sized read. So on a 64-bit arch, a word is 8 bytes long, so when processing the last 4-byte block of the buffer, the 8 bytes starting from the unsafe.Pointer
extend 4 bytes past the end of the buffer (even though only the first four bytes will be read, since the unsafe.Pointer
is immediately cast to *uint32
). So this is a false positive.
The cleanest thing would be to use binary.LittleEndian.Uint32
in place of pointer arithmetic here, but it imposes a slowdown (maybe 20%). I'm surprised the compiler isn't better at handling this...
I'm getting the same issue. Here is a really simple test to reproduce it (I'm running golang version 1.19):
package tmp_test
import (
"testing"
"github.com/spaolacci/murmur3"
)
func TestMurmur3(t *testing.T) {
_ = murmur3.Sum32([]byte("deadletter"))
}
Do you have any updates?
See https://github.com/spaolacci/murmur3/issues/29#issuecomment-1822864930
related issue: https://github.com/pingcap/tidb/issues/29086
We got the following error when running
go test -race
on Go1.15 andgo test -race -d=checkptr
on Go1.13. Does anyone know why this happens?