Apache Beam has a function as follows:
func LoadFunction(ptr uintptr, t reflect.Type) interface{} {
v := reflect.New(t).Elem()
*(*uintptr)(unsafe.Pointer(v.Addr().Pointer())) = (uintptr)(unsafe.Pointer(&ptr))
return v.Interface()
}
When compiled on Go1.12 with -gcflags=-m, we see:
functions.go:43: &ptr escapes to heap
When compiled on Go1.13 with -gcflags=-m, the fact that &ptr escapes is no longer true. The effect of this change is a subtle memory corruption where since &ptr now points to the heap, rather than a copy of the value on the stack.
Git bisect reports that the issue is due to CL/170448, which seems to suggest that this breakage is intentional. The fix the Beam code is relatively straight forward by manually allocating ptr on the heap.
I'm filing an issue to confirm that this is an expected regression.
\cc @mdempsky @dr2chase
Apache Beam has a function as follows:
When compiled on Go1.12 with
-gcflags=-m, we see:When compiled on Go1.13 with
-gcflags=-m, the fact that&ptrescapes is no longer true. The effect of this change is a subtle memory corruption where since&ptrnow points to the heap, rather than a copy of the value on the stack.Git bisect reports that the issue is due to CL/170448, which seems to suggest that this breakage is intentional. The fix the Beam code is relatively straight forward by manually allocating
ptron the heap.I'm filing an issue to confirm that this is an expected regression.
\cc @mdempsky @dr2chase