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

runtime: checkptr incorrectly -race flagging when using &^ arithmetic [1.15 backport] #40934

gopherbot opened this issue Aug 20, 2020 · 4 comments
CherryPickApproved FrozenDueToAge


Copy link

@gopherbot gopherbot commented Aug 20, 2020

@mdempsky requested issue #40917 to be considered for backport to the next 1.15 minor release.

@gopherbot Please consider for backport to Go 1.15. See my rationale for/against at #40917 (comment). Also, that this affected real user code at #40917 (comment).

@gopherbot gopherbot added the CherryPickCandidate label Aug 20, 2020
@gopherbot gopherbot added this to the Go1.15.1 milestone Aug 20, 2020
Copy link

@bcmills bcmills commented Aug 20, 2020

Personally, I would be inclined to backport a fix for anything that causes false-positives in -race mode. We really don't want to encourage users to discount -race reports as false-positives, or (even worse!) to avoid running the race detector due to false-positives in their dependencies.

Copy link

@dmitshur dmitshur commented Aug 21, 2020

Approved per discussion in a release meeting. This backport applies to both 1.15 (this issue) and 1.14 (#40968).

@dmitshur dmitshur added CherryPickApproved and removed CherryPickCandidate labels Aug 21, 2020
Copy link

@gopherbot gopherbot commented Aug 21, 2020

Change mentions this issue: [release-branch.go1.15] cmd/compile: fix checkptr handling of &^

Copy link

@gopherbot gopherbot commented Aug 21, 2020

Closed by merging f454f70 to release-branch.go1.15.

gopherbot pushed a commit that referenced this issue Aug 21, 2020
checkptr has code to recognize &^ expressions, but it didn't take into
account that "p &^ x" gets rewritten to "p & ^x" during walk, which
resulted in false positive diagnostics.

This CL changes walkexpr to mark OANDNOT expressions with Implicit
when they're rewritten to OAND, so that walkCheckPtrArithmetic can
still recognize them later.

It would be slightly more idiomatic to instead mark the OBITNOT
expression as Implicit (as it's a compiler-generated Node), but the
OBITNOT expression might get constant folded. It's not worth the extra
complexity/subtlety of relying on n.Right.Orig, so we set Implicit on
the OAND node instead.

To atone for this transgression, I add documentation for nodeImplicit.

Updates #40917.
Fixes #40934.

Change-Id: I386304171ad299c530e151e5924f179e9a5fd5b8
Run-TryBot: Matthew Dempsky <>
TryBot-Result: Gobot Gobot <>
Reviewed-by: Keith Randall <>
Reviewed-by: Cuong Manh Le <>
(cherry picked from commit e94544c)
Run-TryBot: Dmitri Shuralyov <>
Reviewed-by: Matthew Dempsky <>
@dmitshur dmitshur removed this from the Go1.15.1 milestone Sep 1, 2020
@dmitshur dmitshur added this to the Go1.15.2 milestone Sep 1, 2020
@golang golang locked and limited conversation to collaborators Sep 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
CherryPickApproved FrozenDueToAge
None yet

No branches or pull requests

3 participants