]> Cypherpunks repositories - gostls13.git/commit
runtime: panic if cleanup function closes over cleanup pointer
authorIan Lance Taylor <iant@golang.org>
Fri, 22 Aug 2025 20:47:42 +0000 (13:47 -0700)
committerGopher Robot <gobot@golang.org>
Wed, 26 Nov 2025 06:10:16 +0000 (22:10 -0800)
commiteb63ef9d6676dc0edb112cd297820306a327017a
tree589b7cc96275ff412c7bb6c3686017df05906a03
parent06412288cfd31ab365fe8ee6368742dffa759803
runtime: panic if cleanup function closes over cleanup pointer

This would catch problems like https://go.dev/cl/696295.

Benchmark effect with this CL plus CL 697535:

goos: linux
goarch: amd64
pkg: runtime
cpu: 12th Gen Intel(R) Core(TM) i7-1260P
                     │ /tmp/foo.1  │             /tmp/foo.2             │
                     │   sec/op    │   sec/op     vs base               │
AddCleanupAndStop-16   81.93n ± 1%   82.87n ± 1%  +1.14% (p=0.041 n=10)

For #75066

Change-Id: Ia41d0d6b88baebf6055cb7e5d42bc8210b31630f
Reviewed-on: https://go-review.googlesource.com/c/go/+/714000
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/runtime/mcleanup.go
src/runtime/mcleanup_test.go
src/runtime/testdata/testprog/checkfinalizers.go