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

cmd/compile: invalid pointer found on stack when compiled with -race [1.21 backport] #63743

Closed
gopherbot opened this issue Oct 25, 2023 · 4 comments
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime.
Milestone

Comments

@gopherbot
Copy link

@randall77 requested issue #63657 to be considered for backport to the next 1.21 minor release.

@gopherbot Please open a backport issue for 1.21.

@gopherbot gopherbot added the CherryPickCandidate Used during the release process for point releases label Oct 25, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Oct 25, 2023
@gopherbot gopherbot added this to the Go1.21.4 milestone Oct 25, 2023
@randall77
Copy link
Contributor

This is a rare but serious miscompilation, causing invalid pointers to be seen by the garbage collector.
(It can happen without -race.)

@gopherbot
Copy link
Author

Change https://go.dev/cl/538717 mentions this issue: cmd/compile: ensure pointer arithmetic happens after the nil check

@gopherbot
Copy link
Author

Change https://go.dev/cl/538857 mentions this issue: cmd/compile: handle constant pointer offsets in dead store elimination

@cherrymui cherrymui added the CherryPickApproved Used during the release process for point releases label Nov 1, 2023
@gopherbot gopherbot removed the CherryPickCandidate Used during the release process for point releases label Nov 1, 2023
@gopherbot gopherbot modified the milestones: Go1.21.4, Go1.21.5 Nov 7, 2023
@gopherbot
Copy link
Author

Closed by merging caacf3a to release-branch.go1.21.

gopherbot pushed a commit that referenced this issue Nov 7, 2023
…in dead store elimination

Update #63743

Change-Id: I163c6038c13d974dc0ca9f02144472bc05331826
Reviewed-on: https://go-review.googlesource.com/c/go/+/538595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 43b57b8)
Reviewed-on: https://go-review.googlesource.com/c/go/+/538857
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
gopherbot pushed a commit that referenced this issue Nov 7, 2023
…s after the nil check

Have nil checks return a pointer that is known non-nil. Users of
that pointer can use the result, ensuring that they are ordered
after the nil check itself.

The order dependence goes away after scheduling, when we've fixed
an order. At that point we move uses back to the original pointer
so it doesn't change regalloc any.

This prevents pointer arithmetic on nil from being spilled to the
stack and then observed by a stack scan.

Fixes #63743

Change-Id: I1a5fa4f2e6d9000d672792b4f90dfc1b7b67f6ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/537775
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
(cherry picked from commit 962ccbe)
Reviewed-on: https://go-review.googlesource.com/c/go/+/538717
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CherryPickApproved Used during the release process for point releases compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

3 participants