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

math/big: nat.mulRange produces incorrect results for large input arguments #65025

Closed
griesemer opened this issue Jan 8, 2024 · 1 comment
Closed
Assignees
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@griesemer
Copy link
Contributor

Go version

go version devel go1.22-8eaa7935db Mon Jan 8 18:52:56 2024 +0000 darwin/amd64

Output of go env in your module/workspace:

irrelevant

What did you do?

mulRange(math.MaxUint64 - 3, math.MaxUint64) overflows the internal median computation
(reported by [email protected])

What did you see happen?

incorrect result / stack overflow

What did you expect to see?

correct result

@griesemer griesemer added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 8, 2024
@griesemer griesemer added this to the Go1.22 milestone Jan 8, 2024
@griesemer griesemer self-assigned this Jan 8, 2024
@gopherbot
Copy link
Contributor

Change https://go.dev/cl/554617 mentions this issue: math/big: fix uint64 overflow in nat.mulRange

ezz-no pushed a commit to ezz-no/go-ezzno that referenced this issue Feb 18, 2024
Compute median as a + (b-a)/2 instead of (a + b)/2.
Add additional test cases.

Fixes golang#65025.

Change-Id: Ib716a1036c17f8f33f51e33cedab13512eb7e0be
Reviewed-on: https://go-review.googlesource.com/c/go/+/554617
Reviewed-by: Robert Griesemer <[email protected]>
Auto-Submit: Robert Griesemer <[email protected]>
TryBot-Result: Gopher Robot <[email protected]>
Run-TryBot: Robert Griesemer <[email protected]>
Reviewed-by: Rob Pike <[email protected]>
Reviewed-by: Dmitri Shuralyov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

2 participants