You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some places in the codebase where a model::timeout_clock::duration is accepted as parameter. In these sites this value is commonly added to model::timeout_clock::now().
The issue arises when model::no_timeout is passed as duration parameter like so:
This overflows, which is bad because depending on the nature of the result of the addition, it may be the case that the actual timeout is a very small value. Proof of the overflow is provided in this tiny unit test:
#include <seastar/core/lowres_clock.hh>
#include <seastar/testing/thread_test_case.hh>
SEASTAR_THREAD_TEST_CASE(timer_test) {
const auto max = seastar::lowres_clock_impl::steady_duration::max();
const auto max_tp = seastar::lowres_clock_impl::steady_time_point::max();
const auto now = seastar::lowres_clock_impl::steady_now();
BOOST_CHECK((now + max) == max_tp);
}
Here is the result:
Running 1 test case...
WARNING: debug mode. Not for benchmarking or production
random-seed=2453175103
==1400454==WARNING: ASan doesn't fully support makecontext/swapcontext functions and may produce false positives in some cases!
/home/robert/workspace/redpanda/vbuild/llvm/install/bin/../include/c++/v1/chrono:1249:35: runtime error: signed integer overflow: 62891062 + 9223372036854775807 cannot be represented in type 'long long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /home/robert/workspace/redpanda/vbuild/llvm/install/bin/../include/c++/v1/chrono:1249:35 in
../../../src/v/coproc/tests/tt.cc(18): error: in "timer_test": check (now + max) == max_tp has failed
Why haven't we seen an issue with create_topics? Probably because clients always pass a sane timeout when creating a topic. However this issue was just observed with #3119 during testing and it was found that it can be an issue elsewhere in the codebase too.
There are some places in the codebase where a
model::timeout_clock::duration
is accepted as parameter. In these sites this value is commonly added tomodel::timeout_clock::now()
.The issue arises when
model::no_timeout
is passed as duration parameter like so:This overflows, which is bad because depending on the nature of the result of the addition, it may be the case that the actual timeout is a very small value. Proof of the overflow is provided in this tiny unit test:
Here is the result:
Why haven't we seen an issue with
create_topics
? Probably because clients always pass a sane timeout when creating a topic. However this issue was just observed with #3119 during testing and it was found that it can be an issue elsewhere in the codebase too.JIRA Link: CORE-793
The text was updated successfully, but these errors were encountered: