[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
This commit is contained in:
@ -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();
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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);
|
||||
|
||||
Reference in New Issue
Block a user