Fix UndefinedBehaviorSanitizer error in `retryingPolicyCappedJitteredExponentialBackoff`
Summary: While running some unit tests which happen to call into `folly::futures::retryingPolicyCappedJitteredExponentialBackoff`, I noticed that `retryingJitteredExponentialBackoffDur` was triggering a "float-cast-overflow" error from UndefinedBehaviorSanitizer. It turns out that this only happened if `backoff_min` was 0 and there were at least 1025 retries. The large retry count caused the exponential term in the calculation to become `Infinity`. In floating point, Infinity multiplied by 0 was `NaN`, causing the sanitizer error. Although `backoff_min` should typically not be set to 0 because this effectively disables all backoff, I think there may be cases, such as unit tests, where setting `backoff_min` to 0 does make sense. This commit adds an additional check to handle this unusual case. Reviewed By: yfeldblum Differential Revision: D24122470 fbshipit-source-id: 48a8aede0d22e73cf001dab5eb184e841f3c23aa
Showing
Please register or sign in to comment