You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by ya...@apache.org on 2023/04/13 01:12:20 UTC

[doris] branch branch-1.2-lts updated: [fix](non-vec expr) apply pr #17346 into non-vectorized engine, avoid crashing caused by big depth of expression tree (#18521) (#18595)

This is an automated email from the ASF dual-hosted git repository.

yangzhg 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 314dc63380 [fix](non-vec expr)  apply pr #17346 into non-vectorized engine, avoid crashing caused by big depth of expression tree (#18521) (#18595)
314dc63380 is described below

commit 314dc63380308ed5a7f80bafa300e6f39af068d2
Author: camby <zh...@baidu.com>
AuthorDate: Thu Apr 13 09:12:13 2023 +0800

    [fix](non-vec expr)  apply pr #17346 into non-vectorized engine, avoid crashing caused by big depth of expression tree (#18521) (#18595)
---
 be/src/exprs/expr.cpp       | 8 ++++++++
 be/src/exprs/expr_context.h | 3 +++
 2 files changed, 11 insertions(+)

diff --git a/be/src/exprs/expr.cpp b/be/src/exprs/expr.cpp
index 89e3077e4b..b09bc6cfb1 100644
--- a/be/src/exprs/expr.cpp
+++ b/be/src/exprs/expr.cpp
@@ -524,9 +524,17 @@ Status Expr::prepare(const std::vector<ExprContext*>& ctxs, RuntimeState* state,
 
 Status Expr::prepare(RuntimeState* state, const RowDescriptor& row_desc, ExprContext* context) {
     DCHECK(_type.type != INVALID_TYPE);
+    ++context->_depth_num;
+    if (context->_depth_num > config::max_depth_of_expr_tree) {
+        return Status::InternalError(
+                fmt::format("The depth of the expression tree is too big, make it less than {}",
+                            config::max_depth_of_expr_tree));
+    }
     for (int i = 0; i < _children.size(); ++i) {
         RETURN_IF_ERROR(_children[i]->prepare(state, row_desc, context));
     }
+
+    --context->_depth_num;
     return Status::OK();
 }
 
diff --git a/be/src/exprs/expr_context.h b/be/src/exprs/expr_context.h
index e61d60fd00..6b94a1ab74 100644
--- a/be/src/exprs/expr_context.h
+++ b/be/src/exprs/expr_context.h
@@ -186,6 +186,9 @@ private:
     /// Calls the appropriate Get*Val() function on 'e' and stores the result in result_.
     /// This is used by Exprs to call GetValue() on a child expr, rather than root_.
     void* get_value(Expr* e, TupleRow* row, int precision = 0, int scale = 0);
+
+    /// The depth of expression-tree.
+    int _depth_num = 0;
 };
 
 inline void* ExprContext::get_value(TupleRow* row) {


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