mirror of https://github.com/mongodb/mongo
SERVER-105931 Remove bsoncolumn_helpers.h from ubsan deny (#37450)
GitOrigin-RevId: 1073f04a1a7c605cff233fe79de7291eded900e7
This commit is contained in:
parent
46a114042a
commit
ba5ca89603
|
|
@ -15,7 +15,6 @@ src:src/third_party/immer/dist/immer/detail/hamts/node.hpp
|
|||
# s2 compatibility
|
||||
fun:_ZN8S2CellId14FromFaceIJWrapEiii
|
||||
|
||||
src:src/mongo/bson/column/bsoncolumn_helpers.h
|
||||
src:src/third_party/abseil-cpp/dist/absl/numeric/int128_have_intrinsic.inc
|
||||
|
||||
# SERVER-62972
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
namespace mongo {
|
||||
|
||||
namespace bsoncolumn {
|
||||
|
||||
/**
|
||||
|
|
@ -551,7 +552,7 @@ public:
|
|||
bsoncolumn::scaleIndexForControlByte(control) ==
|
||||
Simple8bTypeUtil::kMemoryAsInteger);
|
||||
|
||||
out += simple8b::sum<Encoding>(ptr + 1, size, lastNonRLEBlock);
|
||||
out = simple8b::add(out, simple8b::sum<Encoding>(ptr + 1, size, lastNonRLEBlock));
|
||||
|
||||
ptr += 1 + size;
|
||||
}
|
||||
|
|
@ -576,7 +577,8 @@ public:
|
|||
bsoncolumn::scaleIndexForControlByte(control) ==
|
||||
Simple8bTypeUtil::kMemoryAsInteger);
|
||||
|
||||
out += simple8b::prefixSum<Encoding>(ptr + 1, size, prefix, lastNonRLEBlock);
|
||||
out = simple8b::add(
|
||||
out, simple8b::prefixSum<Encoding>(ptr + 1, size, prefix, lastNonRLEBlock));
|
||||
|
||||
ptr += 1 + size;
|
||||
}
|
||||
|
|
@ -603,7 +605,8 @@ public:
|
|||
auto encodedDouble = Simple8bTypeUtil::encodeDouble(last, scaleIndex);
|
||||
uassert(9095626, "Invalid double encoding in BSON Column", encodedDouble);
|
||||
lastValue = *encodedDouble;
|
||||
lastValue += simple8b::sum<int64_t>(ptr + 1, size, lastNonRLEBlock);
|
||||
lastValue =
|
||||
simple8b::add(lastValue, simple8b::sum<int64_t>(ptr + 1, size, lastNonRLEBlock));
|
||||
|
||||
last = Simple8bTypeUtil::decodeDouble(lastValue, scaleIndex);
|
||||
|
||||
|
|
@ -636,7 +639,7 @@ public:
|
|||
bsoncolumn::scaleIndexForControlByte(control) ==
|
||||
Simple8bTypeUtil::kMemoryAsInteger);
|
||||
|
||||
out += simple8b::sum<int128_t>(ptr + 1, size, lastNonRLEBlock);
|
||||
out = simple8b::add(out, simple8b::sum<int128_t>(ptr + 1, size, lastNonRLEBlock));
|
||||
|
||||
ptr += 1 + size;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -399,6 +399,18 @@ T sum(const char* buffer, size_t size, uint64_t& prevNonRLE);
|
|||
*/
|
||||
template <typename T>
|
||||
T prefixSum(const char* buffer, size_t size, T& prefix, uint64_t& prevNonRLE);
|
||||
|
||||
/**
|
||||
* Helper that performs signed addition as unsigned to get the defined wrap-around overflow behavior
|
||||
* rather than overflow, which is undefined behavior.
|
||||
*/
|
||||
static constexpr int64_t add(int64_t lhs, int64_t rhs) {
|
||||
return static_cast<int64_t>(static_cast<uint64_t>(lhs) + static_cast<uint64_t>(rhs));
|
||||
}
|
||||
static constexpr int128_t add(int128_t lhs, int128_t rhs) {
|
||||
return static_cast<int128_t>(static_cast<uint128_t>(lhs) + static_cast<uint128_t>(rhs));
|
||||
}
|
||||
|
||||
} // namespace simple8b
|
||||
|
||||
} // namespace mongo
|
||||
|
|
|
|||
|
|
@ -37,16 +37,6 @@ namespace {
|
|||
// Sentinel to represent missing, this value is not encodable in simple8b
|
||||
static constexpr int64_t kMissing = std::numeric_limits<int64_t>::max();
|
||||
|
||||
// Performs addition as unsigned and cast back to signed to get overflow defined to wrapped around
|
||||
// instead of undefined behavior.
|
||||
static constexpr int64_t add(int64_t lhs, int64_t rhs) {
|
||||
return static_cast<int64_t>(static_cast<uint64_t>(lhs) + static_cast<uint64_t>(rhs));
|
||||
}
|
||||
|
||||
static constexpr int128_t add(int128_t lhs, int128_t rhs) {
|
||||
return static_cast<int128_t>(static_cast<uint128_t>(lhs) + static_cast<uint128_t>(rhs));
|
||||
}
|
||||
|
||||
// Simple Simple8b decoder for decoding any basic simple8b block where all bits are used for the
|
||||
// value, decodes signed integer at runtime. Suitable for selectors with many bits per slot. Encoded
|
||||
// should be be machine endian and first slot should start at least significant bit.
|
||||
|
|
|
|||
Loading…
Reference in New Issue