~smspillaz/folly/folly-git-master

Viewing all changes in revision 8971.

  • Committer: Facebook GitHub Bot
  • Author(s): Alex Blanck
  • Date: 2020-10-20 06:42:53 UTC
  • Revision ID: git-v1:c663849fec717409bd7587bc342689b415d58ef7
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

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: