| Issue |
203160
|
| Summary |
[clang][ObjC] Crash in assertion `E->isPRValue() && E->getType()->hasPointerRepresentation() `during Objective‑C _expression_ handling
|
| Labels |
|
| Assignees |
|
| Reporter |
hongtaihu
|
This issue is generated by a fuzzer.
https://godbolt.org/z/c8Pj4vKoa
```objective-c
@interface a
b(a c) {
1+c
```
use
```
-x objective-c -fsyntax-only
```
seems to be introduced since clang 3.3
stacktrace:
```
clang++: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument]
<source>:2:7: error: interface type 'a' cannot be passed by value; did you forget * in 'a'?
2 | b(a c) {
| ^
| *
<source>:2:3: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
2 | b(a c) {
| ^
| int
<source>:2:3: warning: function definition inside an Objective-C container is deprecated [-Wfunction-def-in-objc-container]
<source>:3:8: error: expected ';' after _expression_
3 | 1+c
| ^
| ;
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/ExprConstant.cpp:10005: bool EvaluatePointer(const clang::Expr*, {anonymous}::LValue&, {anonymous}::EvalInfo&, bool): Assertion `E->isPRValue() && E->getType()->hasPointerRepresentation()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -x objective-c -fsyntax-only <source>
1. <eof> parser at end of file
2. <source>:2:10: parsing function body 'b'
3. <source>:2:10: in compound statement ('{}')
#0 0x0000000004385c18 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4385c18)
#1 0x0000000004382a54 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4382a54)
#2 0x0000000004383074 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4383074)
#3 0x00000000042bf2f8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007fe6ea245330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007fe6ea29eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
#6 0x00007fe6ea24527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007fe6ea2288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007fe6ea22881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007fe6ea23b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000000000801ff74 EvaluatePointer(clang::Expr const*, (anonymous namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool) ExprConstant.cpp:0:0
#11 0x0000000008050b64 (anonymous namespace)::PointerExprEvaluator::VisitBinaryOperator(clang::BinaryOperator const*) ExprConstant.cpp:0:0
#12 0x000000000801f495 clang::StmtVisitorBase<llvm::make_const_ptr, (anonymous namespace)::PointerExprEvaluator, bool>::Visit(clang::Stmt const*) ExprConstant.cpp:0:0
#13 0x000000000801fef7 EvaluatePointer(clang::Expr const*, (anonymous namespace)::LValue&, (anonymous namespace)::EvalInfo&, bool) ExprConstant.cpp:0:0
#14 0x000000000800a6b5 Evaluate(clang::APValue&, (anonymous namespace)::EvalInfo&, clang::Expr const*) ExprConstant.cpp:0:0
#15 0x000000000800b2f2 EvaluateAsRValue((anonymous namespace)::EvalInfo&, clang::Expr const*, clang::APValue&) ExprConstant.cpp:0:0
#16 0x000000000800f77e clang::Expr::EvaluateForOverflow(clang::ASTContext const&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x800f77e)
#17 0x0000000006e7a116 clang::Sema::CheckForIntOverflow(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e7a116)
#18 0x0000000006ea474c clang::Sema::CheckCompletedExpr(clang::Expr*, clang::SourceLocation, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ea474c)
#19 0x000000000727e327 clang::Sema::ActOnFinishFullExpr(clang::Expr*, clang::SourceLocation, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x727e327)
#20 0x00000000075a3c4e clang::Sema::ActOnExprStmt(clang::ActionResult<clang::Expr*, true>, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x75a3c4e)
#21 0x0000000006d44544 clang::Parser::ParseExprStatement(clang::Parser::ParsedStmtContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d44544)
#22 0x0000000006d3ba24 clang::Parser::ParseStatementOrDeclarationAfterAttributes(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d3ba24)
#23 0x0000000006d3c409 clang::Parser::ParseStatementOrDeclaration(llvm::SmallVector<clang::Stmt*, 24u>&, clang::Parser::ParsedStmtContext, clang::SourceLocation*, clang::LabelDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d3c409)
#24 0x0000000006d44c2e clang::Parser::ParseCompoundStatementBody(bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d44c2e)
#25 0x0000000006d4544a clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4544a)
#26 0x0000000006c47da3 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c47da3)
#27 0x0000000006c7ef63 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c7ef63)
#28 0x0000000006c3b31b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c3b31b)
#29 0x0000000006c3b9f4 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c3b9f4)
#30 0x0000000006cf35db clang::Parser::ParseObjCInterfaceDeclList(clang::tok::ObjCKeywordKind, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cf35db)
#31 0x0000000006cf4bad clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cf4bad)
#32 0x0000000006cf58d4 clang::Parser::ParseObjCAtDirectives(clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cf58d4)
#33 0x0000000006c4398d clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c4398d)
#34 0x0000000006c444e5 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c444e5)
#35 0x0000000006c448d0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c448d0)
#36 0x0000000006c25393 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c25393)
#37 0x00000000051a9458 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51a9458)
#38 0x0000000005126c9d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5126c9d)
#39 0x00000000052a803d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52a803d)
#40 0x0000000000e21efc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe21efc)
#41 0x0000000000e18b9a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#42 0x0000000000e18d1d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#43 0x0000000004ee4b39 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#44 0x00000000042bf734 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42bf734)
#45 0x0000000004ee5186 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#46 0x0000000004ea2102 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ea2102)
#47 0x0000000004ea30ae clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ea30ae)
#48 0x0000000004eab3a5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4eab3a5)
#49 0x0000000000e1e432 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe1e432)
#50 0x0000000000cc210a main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcc210a)
#51 0x00007fe6ea22a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#52 0x00007fe6ea22a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#53 0x0000000000e18545 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xe18545)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs