Closed
Description
Package unsafe's godocs explicitly state this is safe:
hdr.Data = uintptr(unsafe.Pointer(p)) // case 6 (this case)
But compiling this code does not produce any write barriers:
package p
import (
"reflect"
"unsafe"
)
func F(hdr *reflect.SliceHeader, p *byte) {
hdr.Data = uintptr(unsafe.Pointer(p))
}
func G(hdr *reflect.StringHeader, p *byte) {
hdr.Data = uintptr(unsafe.Pointer(p))
}
We should probably change needwritebarrier(l)
to return true when l
is an ODOTPTR
for accessing reflect.{Slice,String}Header.Data
.
This should probably be backported to 1.8 too?
/cc @aclements @rsc