llvm / llvm-project

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

clang-tidy crash with outdated precompiled header #57265

Open firewave opened 2 years ago

firewave commented 2 years ago
LLVM_SYMBOLIZER_PATH=llvm-symbolizer-15 clang-tidy-15 -checks= -p=/tmp/crash /tmp/crash/test.cpp
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: clang-tidy-15 -checks= -p=/tmp/crash /tmp/crash/test.cpp
 #0 0x00007f762a9e1721 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf01721)
 #1 0x00007f762a9df45e llvm::sys::RunSignalHandlers() (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xeff45e)
 #2 0x00007f762a9e1c4b (/usr/lib/llvm-15/bin/../lib/libLLVM-15.so.1+0xf01c4b)
 #3 0x00007f7634501420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f7632e91340 clang::ASTReader::ParseLanguageOptions(llvm::SmallVector<unsigned long, 64u> const&, bool, clang::ASTReaderListener&, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x2421340)
 #5 0x00007f7632e8f12a clang::ASTReader::ReadOptionsBlock(llvm::BitstreamCursor&, unsigned int, bool, clang::ASTReaderListener&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x241f12a)
 #6 0x00007f7632e93bc8 clang::ASTReader::ReadControlBlock(clang::serialization::ModuleFile&, llvm::SmallVectorImpl<clang::ASTReader::ImportedModule>&, clang::serialization::ModuleFile const*, unsigned int) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x2423bc8)
 #7 0x00007f7632e96c7e clang::ASTReader::ReadASTCore(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, clang::serialization::ModuleFile*, llvm::SmallVectorImpl<clang::ASTReader::ImportedModule>&, long, long, clang::ASTFileSignature, unsigned int) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x2426c7e)
 #8 0x00007f7632ea1815 clang::ASTReader::ReadAST(llvm::StringRef, clang::serialization::ModuleKind, clang::SourceLocation, unsigned int, llvm::SmallVectorImpl<clang::ASTReader::ImportedSubmodule>*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x2431815)
 #9 0x00007f7633092656 clang::CompilerInstance::createPCHExternalASTSource(llvm::StringRef, llvm::StringRef, clang::DisableValidationForModuleKind, bool, clang::Preprocessor&, clang::InMemoryModuleCache&, clang::ASTContext&, clang::PCHContainerReader const&, llvm::ArrayRef<std::shared_ptr<clang::ModuleFileExtension>>, llvm::ArrayRef<std::shared_ptr<clang::DependencyCollector>>, void*, bool, bool, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x2622656)
#10 0x00007f76330921f8 clang::CompilerInstance::createPCHExternalASTSource(llvm::StringRef, clang::DisableValidationForModuleKind, bool, void*, bool) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x26221f8)
#11 0x00007f763311f5c3 clang::FrontendAction::BeginSourceFile(clang::CompilerInstance&, clang::FrontendInputFile const&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x26af5c3)
#12 0x00007f7633094e37 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x2624e37)
#13 0x00007f763334953c clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x28d953c)
#14 0x00007f7635853b0d (/usr/lib/llvm-15/bin/clang-tidy+0x12f2b0d)
#15 0x00007f763334929f clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x28d929f)
#16 0x00007f763334832f clang::tooling::ToolInvocation::run() (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x28d832f)
#17 0x00007f763334ad2e clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/lib/llvm-15/bin/../lib/libclang-cpp.so.15+0x28dad2e)
#18 0x00007f763584ed2f clang::tidy::runClangTidy(clang::tidy::ClangTidyContext&, clang::tooling::CompilationDatabase const&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem>, bool, bool, llvm::StringRef) (/usr/lib/llvm-15/bin/clang-tidy+0x12edd2f)
#19 0x00007f7634ce2592 clang::tidy::clangTidyMain(int, char const**) (/usr/lib/llvm-15/bin/clang-tidy+0x781592)
#20 0x00007f7629594083 __libc_start_main /build/glibc-SzIz7B/glibc-2.31/csu/../csu/libc-start.c:342:3
#21 0x00007f7634cdd3de _start (/usr/lib/llvm-15/bin/clang-tidy+0x77c3de)
Segmentation fault (core dumped)

Other files in the analysis fail with

error: file '/mnt/s/GitHub/cppcheck-fw/lib/timer.h' has been modified since the precompiled header '/mnt/s/GitHub/cppcheck-fw/cmake-build-debug-wsl-ubuntu-2004-clang-15/lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.pch' was built: mtime changed (was 1659630242, now 1660915165) [clang-diagnostic-error]
note: please rebuild precompiled header '/mnt/s/GitHub/cppcheck-fw/cmake-build-debug-wsl-ubuntu-2004-clang-15/lib/CMakeFiles/lib_objs.dir/cmake_pch.hxx.pch'

crash.zip

Ubuntu clang version 15.0.0-++20220818073040+0334c1ac1b02-1~exp1~20220818073137.27

firewave commented 2 years ago

Testing this with trunk is obviously difficult since I need to rebuild the precompiled header with the updated compiler and have it outdated.

llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-tidy