-
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
math/big: Int.Lsh gives wrong results on s390x for n>=128 #42838
Comments
At least when cross-compiling from amd64 with GOARCH=s390x, math/pow10.go seems to compile identically before and after. |
Change https://golang.org/cl/273271 mentions this issue: |
It looks like math/big.Rat.SetString is misbehaving on s390x. For SetString("1e192"), it's producing "3027621884171471837698311284263877940814570137795579187554254752777931419931368381990738248285955635616430044818426562647473833981586768834462721163780572037404681705524261520844063170669576192/1". |
In hex, 1e192 should be (big-endian, 64 bits per line):
But the incorrect value that s390x is producing is:
Notably, the last 6 words are correct, but then the first four words are words 5--7 repeating in cycle. It reminds me of the kind of data corruption you get when you use memcpy() instead of memmove() for overlapping data. |
More reduced test case. Fails on s390x, but passes with -tags=math_big_pure_go:
|
Notably, changing |
Thanks for the detailed bug report @mdempsky. The problem is a forward copy in |
@mundaym You may also want to verify that |
Change https://golang.org/cl/274442 mentions this issue: |
@gopherbot please backport to Go 1.15. This was included in the latest release, but remains an issue without workaround in the previous one. |
Backport issue(s) opened: #45335 (for 1.15). Remember to create the cherry-pick CL(s) as soon as the patch is submitted to master, according to https://golang.org/wiki/MinorReleases. |
The dev.regabi branch has switched cmd/compile to using go/constant to represent compile-time constants, and it appears to be causing one of package math's unit tests to fail only on s390x: https://build.golang.org/log/0af0cbb9e4d7754d6f16f93a8ea452e265037a40
/cc @mundaym @griesemer
The text was updated successfully, but these errors were encountered: