Issue 208615
Summary [ObjC++][module] Crash in ObjCMethodDecl::findPropertyDecl when resolving property accessor in malformed interface
Labels new issue
Assignees
Reporter hongtaihu
    
This input is generated by a fuzzer.
```objc
  module foo;
  @interface PropertySubClass:t
  - (int)potentialProperty;
  @interface PropertySubClass()
  @property int potentialProperty;
  k () PropertySubClass *x = [x potentialProperty]
```

```
   -x objective-c++ -std=c++20 -fsyntax-only
```

Seems to be introduced since clang18.

```
clang++: warning: argument unused during compilation: '-S' [-Wunused-command-line-argument]
<source>:1:10: fatal error: module 'foo' not found
    1 |   module foo;
      |          ^~~~
clang++: /root/llvm-project/llvm/tools/clang/lib/AST/DeclObjC.cpp:1439: const clang::ObjCPropertyDecl* clang::ObjCMethodDecl::findPropertyDecl(bool) const: Assertion `isSynthesizedAccessorStub() && "expected an accessor stub"' 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++ -std=c++20 -fsyntax-only <source>
1.	<eof> parser at end of file
 #0 0x00000000043a2c48 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43a2c48)
 #1 0x000000000439fb64 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x439fb64)
 #2 0x00000000043a0184 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43a0184)
 #3 0x00000000042df218 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #4 0x00007dc9fae45330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
 #5 0x00007dc9fae9eb2c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9eb2c)
 #6 0x00007dc9fae4527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
 #7 0x00007dc9fae288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
 #8 0x00007dc9fae2881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
 #9 0x00007dc9fae3b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x0000000007ed51ba clang::ObjCMethodDecl::findPropertyDecl(bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ed51ba)
#11 0x00000000071d21eb clang::Sema::DiagnoseUseOfDecl(clang::NamedDecl*, llvm::ArrayRef<clang::SourceLocation>, clang::ObjCInterfaceDecl const*, bool, bool, clang::ObjCInterfaceDecl*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x71d21eb)
#12 0x0000000007314d9a clang::SemaObjC::BuildInstanceMessage(clang::Expr*, clang::QualType, clang::SourceLocation, clang::Selector, clang::ObjCMethodDecl*, clang::SourceLocation, llvm::ArrayRef<clang::SourceLocation>, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7314d9a)
#13 0x0000000007315dfc clang::SemaObjC::ActOnInstanceMessage(clang::Scope*, clang::Expr*, clang::Selector, clang::SourceLocation, llvm::ArrayRef<clang::SourceLocation>, clang::SourceLocation, llvm::MutableArrayRef<clang::Expr*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7315dfc)
#14 0x0000000006d49e30 clang::Parser::ParseObjCMessageExpressionBody(clang::SourceLocation, clang::SourceLocation, clang::OpaquePtr<clang::QualType>, clang::Expr*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d49e30)
#15 0x0000000006d4a049 clang::Parser::ParseObjCMessageExpression() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4a049)
#16 0x0000000006d0dc4a clang::Parser::ParseCastExpression(clang::CastParseKind, bool, bool&, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d0dc4a)
#17 0x0000000006d0f2a7 clang::Parser::ParseCastExpression(clang::CastParseKind, bool, clang::TypoCorrectionTypeBehavior, bool, bool*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d0f2a7)
#18 0x0000000006d0f339 clang::Parser::ParseAssignmentExpression(clang::TypoCorrectionTypeBehavior) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d0f339)
#19 0x0000000006d386e0 clang::Parser::ParseInitializer(clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d386e0)
#20 0x0000000006cc72ef clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6cc72ef)
#21 0x0000000006ce6dc2 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+++0x6ce6dc2)
#22 0x0000000006c9244b clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c9244b)
#23 0x0000000006c92b24 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c92b24)
#24 0x0000000006d4d2c0 clang::Parser::ParseObjCInterfaceDeclList(clang::tok::ObjCKeywordKind, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4d2c0)
#25 0x0000000006d4ecc9 clang::Parser::ParseObjCAtInterfaceDeclaration(clang::SourceLocation, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4ecc9)
#26 0x0000000006d4f674 clang::Parser::ParseObjCAtDirectives(clang::ParsedAttributes&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6d4f674)
#27 0x0000000006c9f82d clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c9f82d)
#28 0x0000000006ca0385 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6ca0385)
#29 0x0000000006c7d27a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6c7d27a)
#30 0x00000000051bd7d8 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x51bd7d8)
#31 0x000000000514b75d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x514b75d)
#32 0x000000000529506d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x529506d)
#33 0x0000000000d9f3fc cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9f3fc)
#34 0x0000000000d9600a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#35 0x0000000000d9618d 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
#36 0x0000000004f05f59 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
#37 0x00000000042df654 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42df654)
#38 0x0000000004f06a85 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
#39 0x0000000004ec1b62 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ec1b62)
#40 0x0000000004ec2b7e 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+++0x4ec2b7e)
#41 0x0000000004ececb5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ececb5)
#42 0x0000000000d9b8ea clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9b8ea)
#43 0x0000000000cb80fa main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcb80fa)
#44 0x00007dc9fae2a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#45 0x00007dc9fae2a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#46 0x0000000000d959b5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd959b5)
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

Reply via email to