Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sync/atomic: atomic.Pointer[T] can be misused with type conversions. [1.19 backport] #56638

Closed
gopherbot opened this issue Nov 8, 2022 · 4 comments
Assignees
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Milestone

Comments

@gopherbot
Copy link

@ianlancetaylor requested issue #56603 to be considered for backport to the next 1.19 minor release.

@gopherbot Please backport to 1.19.

This will make it less likely for people to write invalid type conversions with generic atomic types.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Nov 8, 2022
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Nov 8, 2022
@gopherbot gopherbot added this to the Go1.19.4 milestone Nov 8, 2022
@gopherbot
Copy link
Author

Change https://go.dev/cl/448518 mentions this issue: [release-branch.go1.19] sync/atomic: disallow type conversions of atomic.Pointer[T]

@mknyszek mknyszek self-assigned this Nov 8, 2022
@mknyszek
Copy link
Contributor

mknyszek commented Nov 9, 2022

Consensus is that this is unlikely to break users but if it does, it's better to break them sooner rather than later to avoid these type conversions from propagating. Approving.

@mknyszek mknyszek added the CherryPickApproved Used during the release process for point releases label Nov 9, 2022
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Nov 9, 2022
@gopherbot
Copy link
Author

Closed by merging 0dfdf32 to release-branch.go1.19.

gopherbot pushed a commit that referenced this issue Nov 11, 2022
…mic.Pointer[T]

For #56603.
Fixes #56638.

Change-Id: I6af9d80201025ae4028bfaa4a62e5de9ac0c501d
GitHub-Last-Rev: e6ed5e1
GitHub-Pull-Request: #56604
Reviewed-on: https://go-review.googlesource.com/c/go/+/448275
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 6bead8f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/448518
Run-TryBot: Michael Knyszek <mknyszek@google.com>
@gopherbot
Copy link
Author

Change https://go.dev/cl/452438 mentions this issue: [release-branch.go1.19] sync/atomic: allow linked list of atomic pointers again

andrew-d pushed a commit to tailscale/go that referenced this issue Dec 7, 2022
…mic.Pointer[T]

For golang#56603.
Fixes golang#56638.

Change-Id: I6af9d80201025ae4028bfaa4a62e5de9ac0c501d
GitHub-Last-Rev: e6ed5e1
GitHub-Pull-Request: golang#56604
Reviewed-on: https://go-review.googlesource.com/c/go/+/448275
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 6bead8f)
Reviewed-on: https://go-review.googlesource.com/c/go/+/448518
Run-TryBot: Michael Knyszek <mknyszek@google.com>
gopherbot pushed a commit that referenced this issue Dec 9, 2022
…ters again

For #56603, CL 448275 added a _ [0]T field to atomic.Pointer,
so that different kinds of atomic.Pointer are not convertible.

Unfortunately, that breaks code like:

	type List struct {
		Next atomic.Pointer[List]
	}

which should be valid, just as using Next *List is valid.
Instead, we get:

	./atomic_test.go:2533:6: invalid recursive type List
		./atomic_test.go:2533:6: List refers to
		./atomic_test.go:2534:13: "sync/atomic".Pointer refers to
		./atomic_test.go:2533:6: List

Fix by using _[0]*T instead.

For #56638.
Fixes #57124.

Change-Id: Icc4c83c691d35961d20cb14b824223d6c779ac5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/450655
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
(cherry picked from commit b14cf3d)
Reviewed-on: https://go-review.googlesource.com/c/go/+/452438
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
@golang golang locked and limited conversation to collaborators Nov 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime. FrozenDueToAge
Projects
None yet
Development

No branches or pull requests

2 participants