-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: s390x floating point <-> integer conversions clobbering the condition code #39651
Comments
I downloaded https://dl.google.com/go/go1.14.4.linux-s390x.tar.gz and with that binary the example.go code also fails in the same way on s390x. |
Change https://golang.org/cl/238628 mentions this issue: |
Smaller reproducer: // Test that float -> integer conversion doesn't clobber
// flags.
package main
//go:noinline
func f(x, y float64, a, b *bool, r *int64) {
*a = x < y // set flags
*r = int64(x) // clobber flags
*b = x == y // use flags
}
func main() {
var a, b bool
var r int64
f(1, 1, &a, &b, &r)
if a || !b {
panic("comparison incorrect")
}
} The floating point <-> integer conversion instructions set the condition code but the compiler wasn't aware of that behavior causing an incorrect condition code to be seen by a load-on-condition instruction. CL 238628 fixes the issue. Sorry about that. |
I'll take a look at backporting the fix once the CL has been approved. |
Thanks a lot @mundaym ! |
@gopherbot please consider this for a backport This is a bug that affects the control flow of a program running on s390x and therefore can result in it behaving incorrectly. The fix is simple and safe and only affects s390x. |
Backport issue(s) opened: #39689 (for 1.13), #39690 (for 1.14). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
This comment has been minimized.
This comment has been minimized.
Change https://golang.org/cl/242237 mentions this issue: |
Change https://golang.org/cl/242238 mentions this issue: |
…ions as clobbering flags These conversion instructions set the condition code and so should be marked as clobbering flags. Updates #39651. Fixes #39690. Change-Id: I1e3f2cf33337128d321b52ac72f46d1b8798ebd9 Reviewed-on: https://go-review.googlesource.com/c/go/+/242237 Run-TryBot: Michael Munday <mike.munday@ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Ubuntu Groovy on s390x
go env
What did you do?
Run example.go on s390x (works elsewhere): https://play.golang.org/p/CGraP0pNaJi
What did you expect to see?
No errors in the output, i.e.:
This code comes from the gopkg.in/yaml.v2 example in their README.md except I replaced "c: 1" with "c: 1.0" in the
data
variable.What did you see instead?
Initially I thought it was a bug in
gopkg.in/yaml.v2
, and filed an issue there, but I suspect something in go itself now, because either of these silly changes make the code work:Output:
Also makes it work and produces the correct output:
The text was updated successfully, but these errors were encountered: