Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix crash when the expression exceed the depth #3545

Closed
wants to merge 4 commits into from

Conversation

heroicNeZha
Copy link
Contributor

@heroicNeZha heroicNeZha commented Dec 23, 2021

What type of PR is this?

  • bug
  • feature
  • enhancement

What does this PR do?

closing #3393

# when the expression exceed the depth
[ERROR (-1004)]: SyntaxError: The above expression is not a valid expression, because its depth exceeds the maximum depth! near `1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+'

Which issue(s)/PR(s) this PR relates to?

Special notes for your reviewer, ex. impact of this fix, etc:

Additional context/ Design document:

Checklist:

  • Documentation affected (Please add the label if documentation needs to be modified.)
  • Incompatibility (If it breaks the compatibility, please describe it and add the corresponding label.)
  • If it's needed to cherry-pick (If cherry-pick to some branches is required, please label the destination version(s).)
  • Performance impacted: Consumes more CPU/Memory

Release notes:

Please confirm whether to be reflected in release notes and how to describe:

                                                            `

src/parser/parser.yy Outdated Show resolved Hide resolved
Comment on lines 572 to 574
if(!$$->checkDepth()){
throw nebula::GraphParser::syntax_error(@1, "The above expression is not a valid expression, because its depth exceeds the maximum depth!");
}
Copy link
Contributor

@jievince jievince Dec 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure is it better to wrap the check as a macro function. Writing the same check and error messages too many times seems not well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@heroicNeZha heroicNeZha added ready for review ready-for-testing PR: ready for the CI test labels Dec 27, 2021
@@ -575,112 +581,148 @@ expression
$$ = UnaryExpression::makeNegate(qctx->objPool(), $3);
}
scanner.setUnaryMinus(false);
CHECK_DEPTH($$, @1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expression:
   : expression_internal {
        if (visitDepth($1)) {}
        $$ = $1;
    }
    ;

expression_internal
    :  constant_expression {

    }
    ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for review ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Limit the depth of the expression, report an error when it exceeds but not crash
3 participants