From ee76b9796c0be144d036304d155de444cb9ef095 Mon Sep 17 00:00:00 2001 From: HappenLee Date: Wed, 18 Jan 2023 17:58:16 +0800 Subject: [PATCH] [Bug](regresstest) BE Crash in DEBUG mode run regress test (#16042) --- be/src/olap/column_predicate.h | 8 ++++++++ be/src/olap/comparison_predicate.h | 16 ++++++++-------- be/src/olap/in_list_predicate.h | 8 ++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/be/src/olap/column_predicate.h b/be/src/olap/column_predicate.h index 0574eb3c23..e95a444e24 100644 --- a/be/src/olap/column_predicate.h +++ b/be/src/olap/column_predicate.h @@ -221,6 +221,14 @@ public: } protected: + // Just prevent access not align memory address coredump + template + T _get_zone_map_value(void* data_ptr) const { + T res; + memcpy(&res, data_ptr, sizeof(T)); + return res; + } + virtual std::string _debug_string() const = 0; uint32_t _column_id; diff --git a/be/src/olap/comparison_predicate.h b/be/src/olap/comparison_predicate.h index 91ad1705e5..ec2be5b609 100644 --- a/be/src/olap/comparison_predicate.h +++ b/be/src/olap/comparison_predicate.h @@ -150,8 +150,8 @@ public: true); } else { return _operator( - *reinterpret_cast(statistic.first->cell_ptr()) <= _value && - *reinterpret_cast(statistic.second->cell_ptr()) >= _value, + _get_zone_map_value(statistic.first->cell_ptr()) <= _value && + _get_zone_map_value(statistic.second->cell_ptr()) >= _value, true); } } else if constexpr (PT == PredicateType::NE) { @@ -166,8 +166,8 @@ public: true); } else { return _operator( - *reinterpret_cast(statistic.first->cell_ptr()) == _value && - *reinterpret_cast(statistic.second->cell_ptr()) == _value, + _get_zone_map_value(statistic.first->cell_ptr()) == _value && + _get_zone_map_value(statistic.second->cell_ptr()) == _value, true); } } else if constexpr (PT == PredicateType::LT || PT == PredicateType::LE) { @@ -193,8 +193,8 @@ public: return _operator(tmp_min_uint32_value == _value && tmp_max_uint32_value == _value, true); } else { - return *reinterpret_cast(statistic.first->cell_ptr()) == _value && - *reinterpret_cast(statistic.second->cell_ptr()) == _value; + return _get_zone_map_value(statistic.first->cell_ptr()) == _value && + _get_zone_map_value(statistic.second->cell_ptr()) == _value; } } else if constexpr (PT == PredicateType::NE) { if constexpr (Type == TYPE_DATE) { @@ -206,8 +206,8 @@ public: sizeof(uint24_t)); return tmp_min_uint32_value > _value || tmp_max_uint32_value < _value; } else { - return *reinterpret_cast(statistic.first->cell_ptr()) > _value || - *reinterpret_cast(statistic.second->cell_ptr()) < _value; + return _get_zone_map_value(statistic.first->cell_ptr()) > _value || + _get_zone_map_value(statistic.second->cell_ptr()) < _value; } } else if constexpr (PT == PredicateType::LT || PT == PredicateType::LE) { COMPARE_TO_MIN_OR_MAX(second) diff --git a/be/src/olap/in_list_predicate.h b/be/src/olap/in_list_predicate.h index ffc8928715..e85b1280f9 100644 --- a/be/src/olap/in_list_predicate.h +++ b/be/src/olap/in_list_predicate.h @@ -313,8 +313,8 @@ public: sizeof(uint24_t)); return tmp_min_uint32_value <= _max_value && tmp_max_uint32_value >= _min_value; } else { - return *reinterpret_cast(statistic.first->cell_ptr()) <= _max_value && - *reinterpret_cast(statistic.second->cell_ptr()) >= _min_value; + return _get_zone_map_value(statistic.first->cell_ptr()) <= _max_value && + _get_zone_map_value(statistic.second->cell_ptr()) >= _min_value; } } else { return true; @@ -335,8 +335,8 @@ public: sizeof(uint24_t)); return tmp_min_uint32_value > _max_value || tmp_max_uint32_value < _min_value; } else { - return *reinterpret_cast(statistic.first->cell_ptr()) > _max_value || - *reinterpret_cast(statistic.second->cell_ptr()) < _min_value; + return _get_zone_map_value(statistic.first->cell_ptr()) > _max_value || + _get_zone_map_value(statistic.second->cell_ptr()) < _min_value; } } else { return false;