v2pro / plz

Modern Go Programming
https://plz.v2p.ro
Apache License 2.0
95 stars 23 forks source link

panic: runtime error: unsafe pointer arithmetic when running go test -race at golang 1.14 #7

Open teou opened 4 years ago

teou commented 4 years ago

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:

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.
teou commented 4 years ago

@taowen