]> Cypherpunks repositories - gostls13.git/commit
[release-branch.go1.23] runtime: explicitly keep handle alive during getOrAddWeakHandle
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 20 Nov 2024 19:12:58 +0000 (19:12 +0000)
committerGopher Robot <gobot@golang.org>
Wed, 20 Nov 2024 19:59:34 +0000 (19:59 +0000)
commitbe062b7f61486db3c93741e794bd51eda5cc6fce
treee2893ac80dca95a7312b8098074c515ef86e00a9
parentd8adc6c4c7cc21d607a97aeaa6b7ffc4c2d76e65
[release-branch.go1.23] runtime: explicitly keep handle alive during getOrAddWeakHandle

getOrAddWeakHandle is very careful about keeping its input alive across
the operation, but not very careful about keeping the heap-allocated
handle it creates alive. In fact, there's a window in this function
where it is *only* visible via the special. Specifically, the window of
time between when the handle is stored in the special and when the
special actually becomes visible to the GC.

(If we fail to add the special because it already exists, that case is
fine. We don't even use the same handle value, but the one we obtain
from the attached GC-visible special, *and* we return that value, so it
remains live.)

For #70455.
Fixes #70469.

Change-Id: Iadaff0cfb93bcaf61ba2b05be7fa0519c481de82
Reviewed-on: https://go-review.googlesource.com/c/go/+/630316
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/runtime/mheap.go