]> Cypherpunks repositories - gostls13.git/commit
runtime: ensure weak handles end up in their own allocation
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 7 Nov 2025 18:22:29 +0000 (18:22 +0000)
committerGopher Robot <gobot@golang.org>
Fri, 14 Nov 2025 19:15:44 +0000 (11:15 -0800)
commit80c91eedbbf3c041e9b0c03c28fae2c73dbb7df4
tree30f816fc0c7f9748ac51a86337084d5187cbef73
parent7a8d0b5d53dc7be331016b6903707aa256e22c2a
runtime: ensure weak handles end up in their own allocation

Currently weak handles are atomic.Uintptr values that may end up in
a tiny block which can cause all sorts of surprising leaks. See #76007
for one example.

This change pads out the underlying allocation of the atomic.Uintptr to
16 bytes to ensure we bypass the tiny allocator, and it gets its own
block. This wastes 8 bytes per weak handle. We could potentially do
better by using the 8 byte noscan size class, but this can be a
follow-up change.

For #76007.

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