]> git.feebdaed.xyz Git - 0xmirror/go.git/commit
weak: fix weak pointer test to correctly iterate over weak pointers after GC
authorcuishuang <imcusg@gmail.com>
Mon, 24 Nov 2025 06:38:30 +0000 (14:38 +0800)
committerDavid Chase <drchase@google.com>
Mon, 8 Dec 2025 22:39:36 +0000 (14:39 -0800)
commita33bbf1988685215cdf300feb47d2e356e459b3e
treef70860660f0c68abe6797067412ecd5456e1eca6
parenta88a96330f312d08f5d191c66a463b165ac1b96d
weak: fix weak pointer test to correctly iterate over weak pointers after GC

This change fixes a bug in the weak pointer test where the loop was
attempting to iterate over a nil slice (bt) instead of the weak
pointer slice (wt).

After setting bt to nil and running GC, the test should iterate over
the weak pointers to verify they've been cleared, not attempt to
iterate over the now-nil strong references.

Change-Id: Ic0425f59da132257770ed87d1bcea5d2c0a54e07
Reviewed-on: https://go-review.googlesource.com/c/go/+/723600
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Sean Liao <sean@liao.dev>
src/weak/pointer_test.go