From 0afa24bb3f4825fd2a1651e511e4a86d46ffeb7f Mon Sep 17 00:00:00 2001 From: Andrew Noyes Date: Wed, 14 Sep 2022 11:46:15 -0700 Subject: [PATCH] Fix undefined behavior when retries is too large (#8180) fdbclient/PaxosConfigTransaction.actor.cpp:221:77: runtime error: shift exponent 32 is too large for 32-bit type 'int' I confirmed that 1 << 30 is not UB --- fdbclient/PaxosConfigTransaction.actor.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fdbclient/PaxosConfigTransaction.actor.cpp b/fdbclient/PaxosConfigTransaction.actor.cpp index 0918e35062..b940aced7f 100644 --- a/fdbclient/PaxosConfigTransaction.actor.cpp +++ b/fdbclient/PaxosConfigTransaction.actor.cpp @@ -218,8 +218,8 @@ class GetGenerationQuorum { if (self->coordinatorsChangedFuture.isReady()) { throw coordinators_changed(); } - wait(delayJittered( - std::clamp(0.005 * (1 << retries), 0.0, CLIENT_KNOBS->TIMEOUT_RETRY_UPPER_BOUND))); + wait(delayJittered(std::clamp( + 0.005 * (1 << std::min(retries, 30)), 0.0, CLIENT_KNOBS->TIMEOUT_RETRY_UPPER_BOUND))); if (deterministicRandom()->random01() < 0.05) { // Randomly inject a delay of at least the generation // reply timeout, to try to prevent contention between