[llvm-bugs] [Bug 45716] New: Missing a recursion guard for sizeof

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Apr 28 08:31:49 PDT 2020


https://bugs.llvm.org/show_bug.cgi?id=45716

            Bug ID: 45716
           Summary: Missing a recursion guard for sizeof
           Product: clang
           Version: 9.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jynelson at email.sc.edu
                CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
                    richard-llvm at metafoo.co.uk

Created attachment 23412
  --> https://bugs.llvm.org/attachment.cgi?id=23412&action=edit
The output of the shell command mentioned in the bug report

The following command crashes clang:

```
$ { echo 'int i = '; yes 'sizeof ' | head -n 2000; echo 'int;'; } | tr -d '\n'
| clang -x c -
```

I expect this to instead give an error about the expression being too nested,
like clang does for parentheses:

```
$ { echo 'int i = '; yes '( ' | head -n 2000;  } | tr -d '\n' | clang -x c -
<stdin>:1:521: fatal error: bracket nesting level exceeded maximum of 256
```

Extract of the stack trace (it goes on for another 300 stack frames):

#330 0x00007f7dcd91080f ParseCastExpression
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:535:20
#331 0x00007f7dcd91080f
clang::Parser::ParseExprAfterUnaryExprOrTypeTrait(clang::Token const&, bool&,
clang::OpaquePtr<clang::QualType>&, clang::SourceRange&)
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:1924:15
#332 0x00007f7dcd90f3c8 clang::Parser::ParseUnaryExprOrTypeTraitExpression()
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:2037:24
#333 0x00007f7dcd905999 clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState, bool)
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:1204:12
#334 0x00007f7dcd91080f ParseCastExpression
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:535:20
#335 0x00007f7dcd91080f
clang::Parser::ParseExprAfterUnaryExprOrTypeTrait(clang::Token const&, bool&,
clang::OpaquePtr<clang::QualType>&, clang::SourceRange&)
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:1924:15
#336 0x00007f7dcd90f3c8 clang::Parser::ParseUnaryExprOrTypeTraitExpression()
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:2037:24
#337 0x00007f7dcd905999 clang::Parser::ParseCastExpression(bool, bool, bool&,
clang::Parser::TypeCastState, bool)
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:1204:12
#338 0x00007f7dcd91080f ParseCastExpression
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:535:20
#339 0x00007f7dcd91080f
clang::Parser::ParseExprAfterUnaryExprOrTypeTrait(clang::Token const&, bool&,
clang::OpaquePtr<clang::QualType>&, clang::SourceRange&)
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:1924:15
#340 0x00007f7dcd90f3c8 clang::Parser::ParseUnaryExprOrTypeTraitExpression()
/build/llvm-toolchain-9-uSl4bC/llvm-toolchain-9-9/tools/clang/lib/Parse/ParseExpr.cpp:2037:24
clang: error: unable to execute command: Segmentation fault (core dumped)
clang: error: clang frontend command failed due to signal (use -v to see
invocation)
clang version 9.0.0-2~ubuntu18.04.2 (tags/RELEASE_900/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /home/joshua/.local/bin
clang: note: diagnostic msg: PLEASE submit a bug report to
https://bugs.llvm.org/ and include the crash backtrace, preprocessed source,
and associated run script.
clang: note: diagnostic msg: Error generating preprocessed source(s) - ignoring
input from stdin.
clang: note: diagnostic msg: Error generating preprocessed source(s) - no
preprocessable inputs.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200428/7041e9be/attachment-0001.html>


More information about the llvm-bugs mailing list