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 c08568e13e [fix](mem) failure of allocating memory (#13414)
c08568e13e is described below
commit c08568e13e16e9247eb7e5e4b3193bb486b0c5c6
Author: Jerry Hu <[email protected]>
AuthorDate: Tue Oct 18 21:11:30 2022 +0800
[fix](mem) failure of allocating memory (#13414)
When the target size to allocate is 8164, MemPool will return nullptr.
---
be/src/runtime/mem_pool.h | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/be/src/runtime/mem_pool.h b/be/src/runtime/mem_pool.h
index a1db3e6c5d..d11952dd50 100644
--- a/be/src/runtime/mem_pool.h
+++ b/be/src/runtime/mem_pool.h
@@ -231,16 +231,17 @@ private:
// I refers to https://github.com/mcgov/asan_alignment_example.
ChunkInfo& info = chunks_[current_chunk_idx_];
- int64_t aligned_allocated_bytes = BitUtil::RoundUpToMultiplyOfFactor(
- info.allocated_bytes + DEFAULT_PADDING_SIZE, alignment);
- if (aligned_allocated_bytes + size + DEFAULT_PADDING_SIZE <=
info.chunk.size) {
+ int64_t aligned_allocated_bytes =
+ BitUtil::RoundUpToMultiplyOfFactor(info.allocated_bytes,
alignment);
+ auto size_with_padding = size + DEFAULT_PADDING_SIZE;
+ if (aligned_allocated_bytes + size_with_padding <= info.chunk.size) {
// Ensure the requested alignment is respected.
int64_t padding = aligned_allocated_bytes - info.allocated_bytes;
uint8_t* result = info.chunk.data + aligned_allocated_bytes;
- ASAN_UNPOISON_MEMORY_REGION(result, size);
- DCHECK_LE(info.allocated_bytes + size, info.chunk.size);
- info.allocated_bytes += padding + size;
- total_allocated_bytes_ += padding + size;
+ ASAN_UNPOISON_MEMORY_REGION(result, size_with_padding);
+ DCHECK_LE(info.allocated_bytes + size_with_padding,
info.chunk.size);
+ info.allocated_bytes += padding + size_with_padding;
+ total_allocated_bytes_ += padding + size_with_padding;
DCHECK_LE(current_chunk_idx_, chunks_.size() - 1);
return result;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]