llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.08k stars 11.59k forks source link

clang-scan-deps can't handle header units #65903

Open zybreak opened 1 year ago

zybreak commented 1 year ago

clang 16.0.6 command /usr/bin/clang-scan-deps segfaults with the following stack trace

`clang::Lexer::LexDependencyDirectiveToken(clang::Token&) 0x00007f3c7ec90e54 clang::Preprocessor::Lex(clang::Token&) 0x00007f3c7ece185f clang::Preprocessor::DiscardUntilEndOfDirective() 0x00007f3c7eca54e7 clang::Preprocessor::CheckEndOfDirective(char const, bool) 0x00007f3c7ecb4e21 clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, clang::Token&, clang::detail::SearchDirIteratorImpl, clang::FileEntry const) 0x00007f3c7ecc8a0f clang::Preprocessor::HandleDirective(clang::Token&) 0x00007f3c7ecc9759 clang::Lexer::LexDependencyDirectiveToken(clang::Token&) 0x00007f3c7ec90ffa clang::Preprocessor::Lex(clang::Token&) 0x00007f3c7ece185f clang::Preprocessor::CheckEndOfDirective(char const, bool) 0x00007f3c7ecb4c91 clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, clang::Token&, clang::detail::SearchDirIteratorImpl, clang::FileEntry const) 0x00007f3c7ecc8a0f clang::Preprocessor::HandleDirective(clang::Token&) 0x00007f3c7ecc9759 clang::Lexer::LexDependencyDirectiveToken(clang::Token&) 0x00007f3c7ec90ffa clang::Preprocessor::Lex(clang::Token&) 0x00007f3c7ece185f clang::Preprocessor::CheckEndOfDirective(char const, bool) 0x00007f3c7ecb4c91 clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, clang::Token&, clang::detail::SearchDirIteratorImpl, clang::FileEntry const) 0x00007f3c7ecc8a0f clang::Preprocessor::HandleDirective(clang::Token&) 0x00007f3c7ecc9759 clang::Lexer::LexDependencyDirectiveToken(clang::Token&) 0x00007f3c7ec90ffa clang::Preprocessor::Lex(clang::Token&) 0x00007f3c7ece185f clang::Preprocessor::CollectPpImportSuffix(llvm::SmallVectorImpl&) 0x00007f3c7ece6cce clang::Preprocessor::LexAfterModuleImport(clang::Token&) 0x00007f3c7ece72d6 clang::Preprocessor::Lex(clang::Token&) 0x00007f3c7ece1a0b clang::ReadPCHAndPreprocessAction::ExecuteAction() 0x00007f3c8051f0fb clang::FrontendAction::Execute() 0x00007f3c8051e7c9 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) 0x00007f3c804c0d2f

0x00007f3c8065e50f clang::tooling::ToolInvocation::run() 0x00007f3c80692d09 clang::tooling::dependencies::DependencyScanningWorker::computeDependencies(llvm::StringRef, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, clang::tooling::dependencies::DependencyConsumer&, clang::DiagnosticConsumer&, std::optional) 0x00007f3c806597d5 clang::tooling::dependencies::DependencyScanningWorker::computeDependencies(llvm::StringRef, std::vector, std::allocator >, std::allocator, std::allocator > > > const&, clang::tooling::dependencies::DependencyConsumer&, std::optional) 0x00007f3c80659d7c clang::tooling::dependencies::DependencyScanningTool::getP1689ModuleDependencyFile(clang::tooling::CompileCommand const&, llvm::StringRef, std::__cxx11::basic_string, std::allocator >&, std::__cxx11::basic_string, std::allocator >&) 0x00007f3c8065abb3 0x0000557157b8c15c 0x0000557157b904b2 llvm::ThreadPool::processTasks(llvm::ThreadPoolTaskGroup*) 0x00007f3c76da59f4 0x00007f3c76da63ea 0x00007f3c7588c9eb 0x00007f3c75910dfc`
llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-modules

cor3ntin commented 1 year ago

@zybreak would you be able to provide the source code that causes the crash?

zybreak commented 1 year ago

Not in its entirety, but after trial and error i did come to understand the line that caused the segfault. It was an import of a header file. import "some-header.h";