This is an automated email from the ASF dual-hosted git repository.

morningman pushed a commit to branch branch-1.2-lts
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-1.2-lts by this push:
     new 8a9fcfeae8 [Bug](regresstest) BE Crash in DEBUG mode run regress test 
(#16042) (#16597)
8a9fcfeae8 is described below

commit 8a9fcfeae8d4213f9e1cb33e5bd8651ec4112da1
Author: Gabriel <[email protected]>
AuthorDate: Fri Feb 10 14:11:31 2023 +0800

    [Bug](regresstest) BE Crash in DEBUG mode run regress test (#16042) (#16597)
    
    pick #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 9cdd22860f..d1fc57d2a2 100644
--- a/be/src/olap/column_predicate.h
+++ b/be/src/olap/column_predicate.h
@@ -172,6 +172,14 @@ public:
     }
 
 protected:
+    // Just prevent access not align memory address coredump
+    template <class T>
+    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 8856fc4ade..afd0fae686 100644
--- a/be/src/olap/comparison_predicate.h
+++ b/be/src/olap/comparison_predicate.h
@@ -226,8 +226,8 @@ public:
                                  true);
             } else {
                 return _operator(
-                        *reinterpret_cast<const 
T*>(statistic.first->cell_ptr()) <= _value &&
-                                *reinterpret_cast<const 
T*>(statistic.second->cell_ptr()) >= _value,
+                        _get_zone_map_value<T>(statistic.first->cell_ptr()) <= 
_value &&
+                                
_get_zone_map_value<T>(statistic.second->cell_ptr()) >= _value,
                         true);
             }
         } else if constexpr (PT == PredicateType::NE) {
@@ -242,8 +242,8 @@ public:
                                  true);
             } else {
                 return _operator(
-                        *reinterpret_cast<const 
T*>(statistic.first->cell_ptr()) == _value &&
-                                *reinterpret_cast<const 
T*>(statistic.second->cell_ptr()) == _value,
+                        _get_zone_map_value<T>(statistic.first->cell_ptr()) == 
_value &&
+                                
_get_zone_map_value<T>(statistic.second->cell_ptr()) == _value,
                         true);
             }
         } else if constexpr (PT == PredicateType::LT || PT == 
PredicateType::LE) {
@@ -269,8 +269,8 @@ public:
                 return _operator(tmp_min_uint32_value == _value && 
tmp_max_uint32_value == _value,
                                  true);
             } else {
-                return *reinterpret_cast<const 
T*>(statistic.first->cell_ptr()) == _value &&
-                       *reinterpret_cast<const 
T*>(statistic.second->cell_ptr()) == _value;
+                return _get_zone_map_value<T>(statistic.first->cell_ptr()) == 
_value &&
+                       _get_zone_map_value<T>(statistic.second->cell_ptr()) == 
_value;
             }
         } else if constexpr (PT == PredicateType::NE) {
             if constexpr (Type == TYPE_DATE) {
@@ -282,8 +282,8 @@ public:
                        sizeof(uint24_t));
                 return tmp_min_uint32_value > _value || tmp_max_uint32_value < 
_value;
             } else {
-                return *reinterpret_cast<const 
T*>(statistic.first->cell_ptr()) > _value ||
-                       *reinterpret_cast<const 
T*>(statistic.second->cell_ptr()) < _value;
+                return _get_zone_map_value<T>(statistic.first->cell_ptr()) > 
_value ||
+                       _get_zone_map_value<T>(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 b78afa271e..1143f70753 100644
--- a/be/src/olap/in_list_predicate.h
+++ b/be/src/olap/in_list_predicate.h
@@ -315,8 +315,8 @@ public:
                        sizeof(uint24_t));
                 return tmp_min_uint32_value <= _max_value && 
tmp_max_uint32_value >= _min_value;
             } else {
-                return *reinterpret_cast<const 
T*>(statistic.first->cell_ptr()) <= _max_value &&
-                       *reinterpret_cast<const 
T*>(statistic.second->cell_ptr()) >= _min_value;
+                return _get_zone_map_value<T>(statistic.first->cell_ptr()) <= 
_max_value &&
+                       _get_zone_map_value<T>(statistic.second->cell_ptr()) >= 
_min_value;
             }
         } else {
             return true;
@@ -337,8 +337,8 @@ public:
                        sizeof(uint24_t));
                 return tmp_min_uint32_value > _max_value || 
tmp_max_uint32_value < _min_value;
             } else {
-                return *reinterpret_cast<const 
T*>(statistic.first->cell_ptr()) > _max_value ||
-                       *reinterpret_cast<const 
T*>(statistic.second->cell_ptr()) < _min_value;
+                return _get_zone_map_value<T>(statistic.first->cell_ptr()) > 
_max_value ||
+                       _get_zone_map_value<T>(statistic.second->cell_ptr()) < 
_min_value;
             }
         } else {
             return false;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to