Skip to content

Commit 796d42b

Browse files
zhannngchenmorningman
authored andcommitted
[fix](scanner) remove useless _src_block_mem_reuse to avoid core dump while loading (#17559)
The _src_block_mem_reuse variable actually not work, since the _src_block is cleared each time when we call get_block. But current code may cause core dump, see issue #17587. Because we insert some result column generated by expr into dest block, and such a column holds a pointer to some column in original schema. When clearing the data of _src_block, some column's data in dest block is also cleared. e.g. coalesce will return a result column which holds a pointer to some original column, see issue #17588
1 parent 703877e commit 796d42b

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

‎be/src/vec/exec/scan/vfile_scanner.cpp‎

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ Status VFileScanner::prepare(
8080
}
8181

8282
if (_is_load) {
83-
_src_block_mem_reuse = true;
8483
_src_row_desc.reset(new RowDescriptor(_state->desc_tbl(),
8584
std::vector<TupleId>({_input_tuple_desc->id()}),
8685
std::vector<bool>({false})));
@@ -369,7 +368,6 @@ Status VFileScanner::_convert_to_output_block(Block* block) {
369368
size_t rows = _src_block.rows();
370369
auto filter_column = vectorized::ColumnUInt8::create(rows, 1);
371370
auto& filter_map = filter_column->get_data();
372-
auto origin_column_num = _src_block.columns();
373371

374372
for (auto slot_desc : _output_tuple_desc->slots()) {
375373
if (!slot_desc->is_materialized()) {
@@ -381,11 +379,7 @@ Status VFileScanner::_convert_to_output_block(Block* block) {
381379
int result_column_id = -1;
382380
// PT1 => dest primitive type
383381
RETURN_IF_ERROR(ctx->execute(&_src_block, &result_column_id));
384-
bool is_origin_column = result_column_id < origin_column_num;
385-
auto column_ptr =
386-
is_origin_column && _src_block_mem_reuse
387-
? _src_block.get_by_position(result_column_id).column->clone_resized(rows)
388-
: _src_block.get_by_position(result_column_id).column;
382+
column_ptr = _src_block.get_by_position(result_column_id).column;
389383
// column_ptr maybe a ColumnConst, convert it to a normal column
390384
column_ptr = column_ptr->convert_to_full_column_if_const();
391385

@@ -450,11 +444,7 @@ Status VFileScanner::_convert_to_output_block(Block* block) {
450444
}
451445

452446
// after do the dest block insert operation, clear _src_block to remove the reference of origin column
453-
if (_src_block_mem_reuse) {
454-
_src_block.clear_column_data(origin_column_num);
455-
} else {
456-
_src_block.clear();
457-
}
447+
_src_block.clear();
458448

459449
size_t dest_size = block->columns();
460450
// do filter

‎be/src/vec/exec/scan/vfile_scanner.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ class VFileScanner : public VScanner {
110110
int _rows = 0;
111111
int _num_of_columns_from_file;
112112

113-
bool _src_block_mem_reuse = false;
114113
bool _strict_mode;
115114

116115
bool _src_block_init = false;

0 commit comments

Comments
 (0)