commit | 2c6c5a229852db5dff1662b3a80d9a396939412f | [log] [tgz] |
---|---|---|
author | Tom <tomcoupland@monzo.com> | Wed Jan 08 13:59:48 2025 +0000 |
committer | Gopher Robot <gobot@golang.org> | Wed Jan 08 14:41:52 2025 -0800 |
tree | c13718ff3557429132351c874a0bebdd322aed6d | |
parent | 1ce61fe87e0e5dd90752d2b6c5972f9b6918e77c [diff] |
rate: prevent overflows when calculating durationFromTokens Currently, there is a conversion from float64 to int64 when returning the duration needed to accumulate the required number of tokens. When limiters are set with low limits, i.e. 1e-10, the duration needed is greater than math.MaxInt64. As per the language specifications, in these scenarios the outcome is implementation determined. This results in overflows on `amd64`, resulting in no wait, effectively jamming the limiter open. Here we add a check for this scenario, returning InfDuration if the desired duration is greater than math.MaxInt64. Fixes golang/go#71154 Change-Id: I775aab80fcc8563a59aa399844a64ef70b9eb76a Reviewed-on: https://go-review.googlesource.com/c/time/+/641336 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
This repository provides supplementary Go time packages.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://go.dev/doc/contribute.
The git repository is https://go.googlesource.com/time.
The main issue tracker for the time repository is located at https://go.dev/issues. Prefix your issue with “x/time:” in the subject line, so it is easy to find.