-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: inconsistent integer arithmetic result on Go 1.22+arm64 with/without -race #68227
Comments
CC @randall77 @golang/arm |
I can reproduce. I see the problem, it's a missing zero-extension. We start with this code:
which is fine. Then in late lower, we decide that because But then during regalloc, we decide that we need to save/restore We've seen this kind of error before #21963 #66066, and also kind of similar is #59367. My commit message text in CL 568616, which fixed #66066, reads
This issue is the case I needed :) The underlying confusion is that when a type only fills part of a register, the upper part is junk. So just because |
cool, yeah I also noticed that this happens with or without fmt.Println, so I suspected something wrong around regalloc. Glad to hear my repro was what you needed! |
Change https://go.dev/cl/595675 mentions this issue: |
@gopherbot please open backport issue for 1.22. |
Backport issue(s) opened: #68230 (for 1.22). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://go.dev/wiki/MinorReleases. |
DIscussed during the weekly release checkin -- does this bug need to be fixed in 1.21 as well? |
I don't believe so. The rules that triggered the bug were added in 1.22. |
v = ... compute some value, which zeros top 32 bits ... w = zero-extend v We want to remove the zero-extension operation, as it doesn't do anything. But if v is typed as a signed value, and it gets spilled/restored, it might be re-sign-extended upon restore. So the zero-extend isn't actually a NOP when there might be calls or other reasons to spill in between v and w. Fixes golang#68227 Change-Id: I3b30b8e56c7d70deac1fb09d2becc7395acbadf8 Reviewed-on: https://go-review.googlesource.com/c/go/+/595675 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Joedian Reid <[email protected]> Reviewed-by: Cuong Manh Le <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
Go version
go version go1.22.3 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
The following is the small repro that I managed to craft, and I run
go test .
andgo test -race .
.What did you see happen?
I got the assertion failure only for the case with
-race
. Note that this also happens for linux/arm64 but only when Go 1.22.When I briefly run with the different Go version, I got the consistent result but the assertion was failing, meaning that the compiled machine code has some undefined behavior. I suspect that seems the root case.
What did you expect to see?
Consistent results regardless of with or withour
-race
flag.The text was updated successfully, but these errors were encountered: