This release adds -d=checkptr as a compile-time option for adding instrumentation to check that Go code is following unsafe.Pointer safety rules dynamically. This option is enabled by default (except on Windows) with the -race or -msan flags, and can be disabled with -gcflags=all=-d=checkptr=0. Specifically, -d=checkptr checks the following:
1. When converting unsafe.Pointer to *T, the resulting pointer must be aligned appropriately for T.
2. If the result of pointer arithmetic points into a Go heap object, one of the unsafe.Pointer-typed operands must point into the same object.
run go test -race with golang 1.14:
panic: runtime error: unsafe pointer arithmetic at /home/xxxxxxxx/src/github.com/v2pro/plz/gls/goid.go:23
because of the new golang -d=checkptr enabled by -race https://tip.golang.org/doc/go1.14
This release adds -d=checkptr as a compile-time option for adding instrumentation to check that Go code is following unsafe.Pointer safety rules dynamically. This option is enabled by default (except on Windows) with the -race or -msan flags, and can be disabled with -gcflags=all=-d=checkptr=0. Specifically, -d=checkptr checks the following: