Skip to content

Commit

Permalink
ubsan-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Mryange committed May 22, 2024
1 parent a508625 commit 8e9070d
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
2 changes: 1 addition & 1 deletion be/src/olap/memtable_memory_limiter.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class MemTableMemoryLimiter {
int64_t _load_soft_mem_limit = -1;
int64_t _load_safe_mem_permit = -1;

enum Limit { NONE, SOFT, HARD } _last_limit;
enum Limit { NONE, SOFT, HARD } _last_limit = Limit::NONE;
MonotonicStopWatch _log_timer;
static const int64_t LOG_INTERVAL = 1 * 1000 * 1000 * 1000; // 1s

Expand Down
7 changes: 4 additions & 3 deletions be/src/pipeline/exec/exchange_source_operator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ Status ExchangeLocalState::open(RuntimeState* state) {
SCOPED_TIMER(exec_time_counter());
SCOPED_TIMER(_open_timer);
RETURN_IF_ERROR(Base::open(state));

RETURN_IF_ERROR(_parent->cast<ExchangeSourceOperatorX>()._vsort_exec_exprs.clone(
state, vsort_exec_exprs));
auto& p = _parent->cast<ExchangeSourceOperatorX>();
if (p.is_merging()) {
RETURN_IF_ERROR(p._vsort_exec_exprs.clone(state, vsort_exec_exprs));
}
return Status::OK();
}

Expand Down
6 changes: 5 additions & 1 deletion be/src/util/frame_of_reference_coding.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,13 @@ inline uint8_t bits_less_than_64(const uint64_t v) {

// See https://stackoverflow.com/questions/28423405/counting-the-number-of-leading-zeros-in-a-128-bit-integer
inline uint8_t bits_may_more_than_64(const uint128_t v) {
// See https://stackoverflow.com/questions/49580083/builtin-clz-returns-incorrect-value-for-input-zero
if (v == 0) {
return 0;
}
uint64_t hi = v >> 64;
uint64_t lo = v;
int z[3] = {__builtin_clzll(hi), __builtin_clzll(lo) + 64, 128};
int z[3] = {hi == 0 ? 64 : __builtin_clzll(hi), (lo == 0 ? 64 : __builtin_clzll(lo)) + 64, 128};
int idx = !hi + ((!lo) & (!hi));
return 128 - z[idx];
}
Expand Down
6 changes: 4 additions & 2 deletions be/src/util/timezone_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,10 @@ T swapEndianness(T value) {

template <typename T>
T next_from_charstream(int8_t*& src) {
T value = *reinterpret_cast<T*>(src);
src += sizeof(T) / sizeof(int8_t);
T value = 0;
constexpr auto step = sizeof(T) / sizeof(int8_t);
memcpy(&value, src, step);
src += step;
if constexpr (std::endian::native == std::endian::little) {
return swapEndianness(
value); // timezone information files use network endianess, which is big-endian
Expand Down
8 changes: 4 additions & 4 deletions be/src/vec/columns/column_nullable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void ColumnNullable::insert_from(const IColumn& src, size_t n) {
const auto& src_concrete = assert_cast<const ColumnNullable&>(src);
get_nested_column().insert_from(src_concrete.get_nested_column(), n);
auto is_null = src_concrete.get_null_map_data()[n];
_has_null |= is_null;
_update_has_null(is_null);
_get_null_map_data().push_back(is_null);
}

Expand Down Expand Up @@ -561,12 +561,12 @@ void ColumnNullable::sort_column(const ColumnSorter* sorter, EqualFlags& flags,

void ColumnNullable::_update_has_null() {
const UInt8* null_pos = _get_null_map_data().data();
_has_null = simd::contain_byte(null_pos, _get_null_map_data().size(), 1);
_need_update_has_null = false;
bool has_null = simd::contain_byte(null_pos, _get_null_map_data().size(), 1);
_update_has_null(has_null);
}

bool ColumnNullable::has_null(size_t size) const {
if (!_has_null && !_need_update_has_null) {
if (!_need_update_has_null && !_has_null) {
return false;
}
const UInt8* null_pos = get_null_map_data().data();
Expand Down
11 changes: 10 additions & 1 deletion be/src/vec/columns/column_nullable.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class ColumnNullable final : public COWHelper<IColumn, ColumnNullable> {
assert_cast<ColumnType*>(nested_column.get())
->insert_from(src_concrete.get_nested_column(), n);
auto is_null = src_concrete.get_null_map_data()[n];
_has_null |= is_null;
_update_has_null(is_null);
_get_null_map_data().push_back(is_null);
}

Expand Down Expand Up @@ -404,6 +404,15 @@ class ColumnNullable final : public COWHelper<IColumn, ColumnNullable> {
bool _need_update_has_null = true;
bool _has_null;

void _update_has_null(bool has_null) {
if (_need_update_has_null) {
_has_null = has_null;
_need_update_has_null = false;
} else {
_has_null |= has_null;
}
}

void _update_has_null();
template <bool negative>
void apply_null_map_impl(const ColumnUInt8& map);
Expand Down
2 changes: 1 addition & 1 deletion be/src/vec/columns/column_object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class SimpleFieldVisitorToScalarType : public StaticVisitor<size_t> {

private:
TypeIndex type = TypeIndex::Nothing;
bool have_nulls;
bool have_nulls = false;
};

/// Visitor that allows to get type of scalar field
Expand Down

0 comments on commit 8e9070d

Please sign in to comment.