-
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: Subsequent calls to Rat.SetString set incorrect value #31184
Comments
@griesemer I haven't had time to dig into the code yet, but my guess is that e4ba400 is missing a (re)initialization in some case or another. Let me know if you have any trouble reproducing this. |
Change https://golang.org/cl/170158 mentions this issue: |
@aclindsa You're right, pow5 is computed wrongly, it's use previous |
@Gnouc Thanks for the quick response and fix! Would it be worth adding a variant of TestRatSetString (in ratconv_test.go) that uses the same big.Rat between all the tests instead of creating a new one for each SetString call - to be more sure it will catch other variants of this issue that may take different code paths? |
@aclindsa IMHO, a separated test (I added in the CL) is enough, 2 or more are the same. Let wait @griesemer to take a look at it. |
Yes, thanks for adding the test. It will prevent this exact bug from occurring again. My question is whether a single pair of SetString() calls will adequately test all the code flows through this function, and therefore be likely to prevent similar, but slightly different, bugs in the future. |
Change https://golang.org/cl/170641 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
No, as far as I know, the issue is limited to the development branch and has not been released. I've bisected the issue to commit e4ba400.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
See https://play.golang.org/p/o3Oz63_fwGq (doesn't reproduce, because is using the released version) or add the following to src/math/big/rat_test.go with a current build from master:
What did you expect to see?
8.192
What did you see instead?
1024.000
The text was updated successfully, but these errors were encountered: