You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "yiguolei (via GitHub)" <gi...@apache.org> on 2023/03/02 03:21:18 UTC

[GitHub] [doris] yiguolei commented on a diff in pull request #17314: [fix](expr) avoid crashing caused by big depth of expression tree

yiguolei commented on code in PR #17314:
URL: https://github.com/apache/doris/pull/17314#discussion_r1122559002


##########
be/src/vec/exprs/vexpr.cpp:
##########
@@ -85,9 +85,28 @@ VExpr::VExpr(const TypeDescriptor& type, bool is_slotref, bool is_nullable)
 }
 
 Status VExpr::prepare(RuntimeState* state, const RowDescriptor& row_desc, VExprContext* context) {
+    context->_depth_num++;
+    if (context->_depth_num > config::max_depth_of_expr_tree) {
+        return Status::InternalError(
+                "The depth of the expression tree is too big, make it less than {}",
+                config::max_depth_of_expr_tree);
+    }
+
+    if (_children.empty()) {
+        return Status::OK();
+    }
+
+    int old_depth = context->_depth_num;
+    int max_child_depth = 0;
     for (int i = 0; i < _children.size(); ++i) {
         RETURN_IF_ERROR(_children[i]->prepare(state, row_desc, context));
+        if ((context->_depth_num - old_depth) > max_child_depth) {

Review Comment:
   --context->_depth_num   is OK?



-- 
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.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

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


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