You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by yi...@apache.org on 2022/07/13 00:31:04 UTC

[doris] branch master updated: [Bug][Memtable] fix core dump on int128 because not aligned by 16 byte (#10775)

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

yiguolei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new 4190f7354c [Bug][Memtable] fix core dump on int128 because not aligned by 16 byte (#10775)
4190f7354c is described below

commit 4190f7354cccdee408e8e258448ee37aadf652e3
Author: Pxl <95...@qq.com>
AuthorDate: Wed Jul 13 08:30:58 2022 +0800

    [Bug][Memtable] fix core dump on int128 because not aligned by 16 byte (#10775)
    
    * fix core dump on int128 because not aligned by 16 byte
    
    * update
---
 be/src/olap/memtable.cpp  | 2 +-
 be/src/olap/memtable.h    | 2 +-
 be/src/runtime/mem_pool.h | 8 ++++++++
 3 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/be/src/olap/memtable.cpp b/be/src/olap/memtable.cpp
index b01cf3fcff..61035f13db 100644
--- a/be/src/olap/memtable.cpp
+++ b/be/src/olap/memtable.cpp
@@ -179,7 +179,7 @@ void MemTable::_insert_one_row_from_block(RowInBlock* row_in_block) {
         _aggregate_two_row_in_block(row_in_block, _vec_hint.curr->key);
     } else {
         row_in_block->init_agg_places(
-                (char*)_table_mem_pool->allocate(_total_size_of_aggregate_states),
+                (char*)_table_mem_pool->allocate_aligned(_total_size_of_aggregate_states, 16),
                 _offsets_of_aggregate_states.data());
         for (auto cid = _schema->num_key_columns(); cid < _schema->num_columns(); cid++) {
             auto col_ptr = _input_mutable_block.mutable_columns()[cid].get();
diff --git a/be/src/olap/memtable.h b/be/src/olap/memtable.h
index 0ff15789cc..3fbfe8288e 100644
--- a/be/src/olap/memtable.h
+++ b/be/src/olap/memtable.h
@@ -91,7 +91,7 @@ private:
             _agg_state_offset = agg_state_offset;
         }
 
-        char* agg_places(size_t offset) { return _agg_mem + _agg_state_offset[offset]; }
+        char* agg_places(size_t offset) const { return _agg_mem + _agg_state_offset[offset]; }
     };
 
     class RowInBlockComparator {
diff --git a/be/src/runtime/mem_pool.h b/be/src/runtime/mem_pool.h
index 769e5d67ae..02842b9752 100644
--- a/be/src/runtime/mem_pool.h
+++ b/be/src/runtime/mem_pool.h
@@ -104,9 +104,17 @@ public:
     /// of the current chunk. Creates a new chunk if there aren't any chunks
     /// with enough capacity.
     uint8_t* allocate(int64_t size, Status* rst = nullptr) {
+        // TODO: rethink if DEFAULT_ALIGNMENT should be changed, malloc is aligned by 16.
         return allocate<false>(size, DEFAULT_ALIGNMENT, rst);
     }
 
+    uint8_t* allocate_aligned(int64_t size, int alignment, Status* rst = nullptr) {
+        DCHECK_GE(alignment, 1);
+        DCHECK_LE(alignment, config::memory_max_alignment);
+        DCHECK_EQ(BitUtil::RoundUpToPowerOfTwo(alignment), alignment);
+        return allocate<false>(size, alignment, rst);
+    }
+
     /// Same as Allocate() expect add a check when return a nullptr
     Status allocate_safely(int64_t size, uint8_t*& ret, Status* rst = nullptr) {
         return allocate_safely<false>(size, DEFAULT_ALIGNMENT, ret, rst);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org