]> Cypherpunks repositories - gostls13.git/commit
reflect: keep pointer register results alive in callMethod
authorCherry Zhang <cherryyz@google.com>
Wed, 14 Apr 2021 03:41:45 +0000 (23:41 -0400)
committerCherry Zhang <cherryyz@google.com>
Wed, 14 Apr 2021 16:37:06 +0000 (16:37 +0000)
commitef36e4fd0eec3283a43d03bc6bff7da4e5e03c06
tree6cbc90d69cbd92bd1b84e00fc6a2e5442461265d
parentad44dfb0fda522df08e133d1f909bfe535c4b4be
reflect: keep pointer register results alive in callMethod

When callMethod calls the underlying method, after reflectcall
it gets the result registers in "Ints" slots but not in "Ptrs"
slots. If the GC runs at this point, it may lose track of those
pointers and free the memory they point to.

To make sure the GC sees the pointer results, copy "Ints" to
"Ptrs", and keep them alive until we return to the caller.

This fixes test/fixedbugs/issue27695.go with register ABI.

Change-Id: I4092c91bcbd6954683740a12d91d689900446875
Reviewed-on: https://go-review.googlesource.com/c/go/+/309909
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/reflect/abi.go
src/reflect/value.go