forked from continuwuation/rocksdb
Summary: **Context/Summary:** Due to double's 53-bit mantissa limitation, large uint64_t values lose precision when converted to double. Value equals to or smaller than UINT64_MAX (but greater than 2^64 - 1024) round up to 2^64 since rounding up results in less error than rounding down, which exceeds UINT64_MAX. `std::numeric_limits<uint64_t>::max() / op1 < op2` won't catch those cases. Casting such out-of-range doubles back to uint64_t causes undefined behavior. T Pull Request resolved: https://github.com/facebook/rocksdb/pull/14132 UndefinedBehaviorSanitizer: undefined-behavior options/cf_options.cc:1087:32 in ``` before the fix but not after. Test Plan: ``` COMPILE_WITH_ASAN=1 COMPILE_WITH_UBSAN=1 CC=clang-18 CXX=clang++-18 ROCKSDB_DISABLE_ALIGNED_NEW=1 USE_CLANG=1 make V=1 -j55 db_stress python3 tools/db_crashtest.py --simple blackbox --compact_range_one_in=5 --target_file_size_base=9223372036854775807 // Half of std::numeric_limits<uint64_t>::max() ``` It fails with ``` stderr: options/cf_options.cc:1087:32: runtime error: 1.84467e+19 is outside the range of representable values of type 'unsigned long' Reviewed By: pdillinger Differential Revision: D87434936 Pulled By: hx235 fbshipit-source-id: 65563edf9faf732410bdba8b9e4b7fd61b958169 |
||
|---|---|---|
| .. | ||
| cf_options.cc | ||
| cf_options.h | ||
| configurable.cc | ||
| configurable_helper.h | ||
| configurable_test.cc | ||
| configurable_test.h | ||
| customizable.cc | ||
| customizable_test.cc | ||
| db_options.cc | ||
| db_options.h | ||
| offpeak_time_info.cc | ||
| offpeak_time_info.h | ||
| options.cc | ||
| options_helper.cc | ||
| options_helper.h | ||
| options_parser.cc | ||
| options_parser.h | ||
| options_settable_test.cc | ||
| options_test.cc | ||