liutang123 opened a new issue #5430:
URL: https://github.com/apache/incubator-doris/issues/5430


   **Describe the bug**
   ```select t1.id, t2.name from t1 left join t2 on t1.id = t2.id```
   This query's second tuple may be null.
   If we query the column from t2, BE may core.
   
   There are the following stacks:
   
   ```
   Program terminated with signal 11, Segmentation fault.
   #0  is_null (offset=..., offset=..., this=<optimized out>) at 
be/src/runtime/tuple.h:138 
   #1  get_value (row=0xcd1f2e0a8, expr=0x708687000) at 
be/src/exprs/slot_ref.h:103
   
   ref->_tuple_idx = 1
   t = row->_tuples[1] = (doris::Tuple *) 0x8cafe518f6190425 
   
   #2  doris::ExprContext::get_value (this=0xea4e8d680, 
row=row@entry=0xcd1f2e0a8)
       at be/src/exprs/expr_context.cpp:252
   #3  0x0000000001575806 in doris::PartitionedHashTableCtx::EvalRow 
(this=this@entry=0x4f87d4f00, row=row@entry=0xcd1f2e0a8, ctxs=...,
       expr_values=expr_values@entry=0x4ba6fc188 "ŝ\034\201", 
expr_values_null=expr_values_null@entry=0x62b014031 "\001\001\001\001")
       at be/src/exec/partitioned_hash_table.cc:224
   #4  0x0000000001531e87 in EvalProbeRow (expr_values_null=<optimized out>, 
expr_values=<optimized out>, row=0xcd1f2e0a8, this=0x4f87d4f00)
       at be/src/exec/partitioned_hash_table.h:418
   #5  EvalAndHashProbe (row=0xcd1f2e0a8, this=0x4f87d4f00)
       at be/src/exec/partitioned_hash_table.inline.h:40
     
   #6  doris::PartitionedAggregationNode::EvalAndHashPrefetchGroup<false> 
(this=this@entry=0x6c577ec00, batch=batch@entry=0xced624dc0, 
start_row_idx=start_row_idx@entry=0,  ht_ctx=ht_ctx@entry=0x4f87d4f00) at 
be/src/exec/partitioned_aggregation_node_ir.cc:79
   
   p *(((doris::Tuple**)( batch_iter._row)) + 1 )
   $2 = (doris::Tuple *) 0x8cafe518f6190425 
   0x8cafe518f6190425 is a illegal ptr.
   
   #7  0x0000000001531718 in 
doris::PartitionedAggregationNode::ProcessBatchStreaming 
(this=this@entry=0x6c577ec00, needs_serialize=<optimized out>, 
in_batch=0xced624dc0,
       out_batch=out_batch@entry=0xdf1d1c420, ht_ctx=0x4f87d4f00, 
remaining_capacity=0x7fda02579160)
       at be/src/exec/partitioned_aggregation_node_ir.cc:176
       
   #8  0x000000000152a518 in 
doris::PartitionedAggregationNode::GetRowsStreaming 
(this=this@entry=0x6c577ec00, state=state@entry=0x1094ec2000,
       out_batch=out_batch@entry=0xdf1d1c420) at 
be/src/exec/partitioned_aggregation_node.cc:550
   #9  0x000000000152db71 in doris::PartitionedAggregationNode::GetNextInternal 
(this=this@entry=0x6c577ec00, state=0x1094ec2000, 
row_batch=row_batch@entry=0xdf1d1c420,
       eos=0x194ff81a9) at be/src/exec/partitioned_aggregation_node.cc:412
   #10 0x000000000152dd1f in doris::PartitionedAggregationNode::get_next 
(this=0x6c577ec00, state=<optimized out>, row_batch=0xdf1d1c420, eos=<optimized 
out>)
       at be/src/exec/partitioned_aggregation_node.cc:335
   #11 0x000000000104bfdf in doris::PlanFragmentExecutor::get_next_internal 
(this=this@entry=0x194ff8070, batch=batch@entry=0x7fda02579380)
       at be/src/runtime/plan_fragment_executor.cpp:481
   ```
   
   **To Reproduce**
   ```
   CREATE TABLE `t1` (
     `id` bigint(20) NULL COMMENT "",
     `id1` bigint(20) NULL COMMENT ""
   ) ENGINE=OLAP
   AGGREGATE KEY(`id`, `id1`)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`id1`) BUCKETS 2
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "V2"
   );
   
   insert into t1 values (1, 2);
   
   CREATE TABLE `t2` (
     `id` bigint(20) NULL COMMENT "",
     name  varchar(10) NULL COMMENT ""
   ) ENGINE=OLAP
   AGGREGATE KEY(`id`, name)
   COMMENT "OLAP"
   DISTRIBUTED BY HASH(`id`) BUCKETS 1
   PROPERTIES (
   "replication_num" = "1",
   "in_memory" = "false",
   "storage_format" = "V2"
   );
   select grouping_id(t1.id), t1.id, max(name) from  
   t1 left join t2 
   on t1.id1 = t2.id 
   group by grouping sets (   (id),   () );
   ```
   The bug does not recur stably.
   In `PartitionedAggregationNode::GetRowsStreaming`, The child_batch's 
_tuple_ptrs is unpredictable.  
   
   **Expected behavior**
   BE may core.
   
   **Screenshots**
   
![image](https://user-images.githubusercontent.com/17537020/109421095-dfef4f00-7a10-11eb-95ca-f81c1bd436c9.png)
   
   I will try to repair it in a PR later.
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



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

Reply via email to