Issue 172425
Summary [clang-tidy] `readability-math-missing-parentheses` crashes given extreme input
Labels clang-tidy, crash-on-valid
Assignees
Reporter zeyi2
    Reproduce: https://clang-tidy.godbolt.org/z/cxWxEzh66

```
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.	Program arguments: /clang-tidy --checks=readability-math-missing-parentheses <source>
1.	<source>:1:1260: current parser token '('
2.	<source>:1:12: parsing function body 'main'
3.	<source>:1:12: in compound statement ('{}')
  #0 0x00000000055bbea8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/clang-tidy+0x55bbea8)
 #1 0x00000000055b9074 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
  #2 0x000071a5aa842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
  #3 0x0000000002d8600d clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d8600d)
  #4 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
  #5 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
  #6 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
  #7 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
  #8 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
  #9 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #10 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #11 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #12 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #13 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #14 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #15 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #16 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #17 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #18 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #19 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #20 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #21 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #22 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #23 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #24 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #25 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #26 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #27 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #28 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #29 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #30 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #31 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #32 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #33 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #34 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #35 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #36 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #37 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #38 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #39 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #40 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #41 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #42 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #43 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #44 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #45 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #46 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #47 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #48 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #49 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #50 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #51 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #52 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #53 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #54 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #55 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #56 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #57 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #58 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #59 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #60 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #61 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #62 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #63 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #64 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #65 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #66 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #67 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #68 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #69 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #70 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #71 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #72 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #73 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #74 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #75 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #76 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #77 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #78 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #79 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #80 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #81 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #82 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #83 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #84 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #85 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #86 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #87 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d82179)
 #88 0x0000000002d86645 clang::Parser::ParseParenExpression(clang::ParenParseOption&, bool, clang::ParenExprKind, clang::TypoCorrectionTypeBehavior, clang::OpaquePtr<clang::QualType>&, clang::SourceLocation&) (/clang-tidy+0x2d86645)
 #89 0x0000000002d7bf0e clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7bf0e)
 #90 0x0000000002d7d23a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/clang-tidy+0x2d7d23a)
 #91 0x0000000002d7d429 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/clang-tidy+0x2d7d429)
 #92 0x0000000002d82179 clang::Parser::ParseExpression(clang::TypoCorrectionTypeBehavior) (/clang<truncated>Please see the issue for the entire body.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to