[fix](memory) fix bug that ~BitShufflePageDecoder destroys uninitialized chunk (#7172)
Added a safe way to destroy Chunk.
This commit is contained in:
@ -216,9 +216,7 @@ public:
|
||||
_cur_index(0) {}
|
||||
|
||||
~BitShufflePageDecoder() {
|
||||
if (_chunk.size != 0) {
|
||||
ChunkAllocator::instance()->free(_chunk);
|
||||
}
|
||||
ChunkAllocator::instance()->free(_chunk);
|
||||
}
|
||||
|
||||
Status init() override {
|
||||
|
||||
@ -27,9 +27,9 @@ namespace doris {
|
||||
// will result in recompilation of all files. So, we put it in a
|
||||
// file to keep this file simple and infrequently changed.
|
||||
struct Chunk {
|
||||
uint8_t* data;
|
||||
size_t size;
|
||||
int core_id;
|
||||
uint8_t* data = nullptr;
|
||||
size_t size = 0;
|
||||
int core_id = -1;
|
||||
};
|
||||
|
||||
} // namespace doris
|
||||
|
||||
@ -170,6 +170,9 @@ bool ChunkAllocator::allocate(size_t size, Chunk* chunk) {
|
||||
}
|
||||
|
||||
void ChunkAllocator::free(const Chunk& chunk) {
|
||||
if (chunk.core_id == -1) {
|
||||
return;
|
||||
}
|
||||
int64_t old_reserved_bytes = _reserved_bytes;
|
||||
int64_t new_reserved_bytes = 0;
|
||||
do {
|
||||
@ -190,7 +193,6 @@ void ChunkAllocator::free(const Chunk& chunk) {
|
||||
_arenas[chunk.core_id]->push_free_chunk(chunk.data, chunk.size);
|
||||
}
|
||||
|
||||
|
||||
bool ChunkAllocator::allocate_align(size_t size, Chunk* chunk) {
|
||||
return allocate(BitUtil::RoundUpToPowerOfTwo(size), chunk);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user