llvm / llvm-project

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

Segmentation fault running Clang-tidy-16 #93171

Open Martsva opened 5 months ago

Martsva commented 5 months ago

I am getting a segmentation fault when running clang-tidy-16 (v 16.0.6) inside of my Debian 11 dev container. My architecture is aarch64. I am compiling using CMake (3.18.4) and GCC (10.2.1), and have activated clang-tidy in the CMakeLists.txt: set(CMAKE_CXX_CLANG_TIDY clang-tidy-16)

I am getting the following error trace:

Error running 'clang-tidy-16': 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-16 --extra-arg-before=--driver-mode=g++ /workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp -- /usr/bin/aarch64-linux-gnu-g++ -I/workspaces/vessel-systems/buildFolder -I/workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs -I/workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/. -I/workspaces/vessel-systems/comps/libs/dbus-lib -I/workspaces/vessel-systems/comps/realtime-libraries -I/workspaces/vessel-systems/comps/realtime-libraries/. -isystem /usr/include/eigen3 -std=c++17 -O2 -g -DNDEBUG -W -Wall -Wextra -O3 -g -Wpedantic -Werror -Wconversion -Wsign-conversion -Wimplicit-fallthrough -march=armv8-a -mtune=cortex-a53 -o CMakeFiles/inertial-navigation-lib.dir/inertial-navigation.cpp.o -c /workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp
1.      <eof> parser at end of file
2.      ASTMatcher: Processing 'bugprone-unchecked-optional-access' against:
        CXXMethodDecl InertialNavigation::estimate_system_state : </workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp:30:1, line:83:1>
--- Bound Nodes Begin ---
    T - { RecordType : ESKF::NominalState }
    fun - { CXXMethodDecl InertialNavigation::estimate_system_state : </workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp:30:1, line:83:1> }
--- Bound Nodes End ---
 #0 0x0000ffff87f90730 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfb5730)
 #1 0x0000ffff87f8e948 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfb3948)
 #2 0x0000ffff87f90f7c (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfb5f7c)
 #3 0x0000ffff919428fc (linux-vdso.so.1+0x8fc)
 #4 0x0000ffff8febc940 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f45940)
 #5 0x0000ffff8febb2a4 clang::dataflow::transfer(clang::dataflow::StmtToEnvMap const&, clang::Stmt const&, clang::dataflow::Environment&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f442a4)
 #6 0x0000ffff8febef90 clang::dataflow::transferCFGBlock(clang::CFGBlock const&, clang::dataflow::AnalysisContext&, std::function<void (clang::CFGElement const&, clang::dataflow::TypeErasedDataflowAnalysisState const&)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f47f90)
 #7 0x0000ffff8febf718 clang::dataflow::runTypeErasedDataflowAnalysis(clang::dataflow::ControlFlowContext const&, clang::dataflow::TypeErasedDataflowAnalysis&, clang::dataflow::Environment const&, std::function<void (clang::CFGElement const&, clang::dataflow::TypeErasedDataflowAnalysisState const&)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f48718)
 #8 0x0000aaaade884a7c llvm::Expected<std::vector<std::optional<clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice> >, std::allocator<std::optional<clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice> > > > > clang::dataflow::runDataflowAnalysis<clang::dataflow::UncheckedOptionalAccessModel>(clang::dataflow::ControlFlowContext const&, clang::dataflow::UncheckedOptionalAccessModel&, clang::dataflow::Environment const&, std::function<void (clang::CFGElement const&, clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice> const&)>) (/usr/lib/llvm-16/bin/clang-tidy+0x9c4a7c)
 #9 0x0000aaaade884550 clang::tidy::bugprone::UncheckedOptionalAccessCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/usr/lib/llvm-16/bin/clang-tidy+0x9c4550)
#10 0x0000aaaadee109c8 (/usr/lib/llvm-16/bin/clang-tidy+0xf509c8)
#11 0x0000aaaadee401b0 clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/usr/lib/llvm-16/bin/clang-tidy+0xf801b0)
#12 0x0000aaaadee1032c (/usr/lib/llvm-16/bin/clang-tidy+0xf5032c)
#13 0x0000aaaadee12f08 (/usr/lib/llvm-16/bin/clang-tidy+0xf52f08)
#14 0x0000aaaadee1bc48 (/usr/lib/llvm-16/bin/clang-tidy+0xf5bc48)
#15 0x0000aaaadee135f8 (/usr/lib/llvm-16/bin/clang-tidy+0xf535f8)
#16 0x0000aaaadede6ab4 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/usr/lib/llvm-16/bin/clang-tidy+0xf26ab4)
#17 0x0000ffff9060411c clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x268d11c)
#18 0x0000ffff8eb3f6b8 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbc86b8)
#19 0x0000ffff905cf608 clang::FrontendAction::Execute() (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x2658608)
#20 0x0000ffff90564904 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x25ed904)
#21 0x0000ffff907c3cd4 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284ccd4)
#22 0x0000aaaadf3569ac (/usr/lib/llvm-16/bin/clang-tidy+0x14969ac)
#23 0x0000ffff907c39ac clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284c9ac)
#24 0x0000ffff907c2b38 clang::tooling::ToolInvocation::run() (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284bb38)
#25 0x0000ffff907c4f58 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284df58)
#26 0x0000aaaadf3536a0 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-16/bin/clang-tidy+0x14936a0)
#27 0x0000aaaade6ee4cc clang::tidy::clangTidyMain(int, char const**) (/usr/lib/llvm-16/bin/clang-tidy+0x82e4cc)
#28 0x0000ffff86be0e18 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x20e18)
#29 0x0000aaaade6e9ff8 _start (/usr/lib/llvm-16/bin/clang-tidy+0x829ff8)
Segmentation fault

If I compile using Clang 16.0.6, I get the following error trace:

Error running 'clang-tidy-16': 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-16 --extra-arg-before=--driver-mode=g++ /workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp -- /usr/bin/clang++-16 -I/workspaces/vessel-systems/buildFolder -I/workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs -I/workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/. -I/workspaces/vessel-systems/comps/libs/dbus-lib -I/workspaces/vessel-systems/comps/realtime-libraries -I/workspaces/vessel-systems/comps/realtime-libraries/. -isystem /usr/include/eigen3 -std=c++17 -O2 -g -DNDEBUG -W -Wall -Wextra -O3 -g -Wpedantic -Werror -Wconversion -Wsign-conversion -Wimplicit-fallthrough -march=armv8-a -mtune=cortex-a53 -o CMakeFiles/inertial-navigation-lib.dir/inertial-navigation.cpp.o -c /workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp
1.      <eof> parser at end of file
2.      ASTMatcher: Processing 'bugprone-unchecked-optional-access' against:
        CXXMethodDecl InertialNavigation::estimate_system_state : </workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp:30:1, line:83:1>
--- Bound Nodes Begin ---
    T - { RecordType : ESKF::NominalState }
    fun - { CXXMethodDecl InertialNavigation::estimate_system_state : </workspaces/vessel-systems/comps/realtime-libraries/inertial-navigation-libs/inertial-navigation.cpp:30:1, line:83:1> }
--- Bound Nodes End ---
 #0 0x0000ffff913a9730 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfb5730)
 #1 0x0000ffff913a7948 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfb3948)
 #2 0x0000ffff913a9f7c (/usr/lib/llvm-16/bin/../lib/libLLVM-16.so.1+0xfb5f7c)
 #3 0x0000ffff9ad5b8fc (linux-vdso.so.1+0x8fc)
 #4 0x0000ffff992d5940 (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f45940)
 #5 0x0000ffff992d42a4 clang::dataflow::transfer(clang::dataflow::StmtToEnvMap const&, clang::Stmt const&, clang::dataflow::Environment&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f442a4)
 #6 0x0000ffff992d7f90 clang::dataflow::transferCFGBlock(clang::CFGBlock const&, clang::dataflow::AnalysisContext&, std::function<void (clang::CFGElement const&, clang::dataflow::TypeErasedDataflowAnalysisState const&)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f47f90)
 #7 0x0000ffff992d8718 clang::dataflow::runTypeErasedDataflowAnalysis(clang::dataflow::ControlFlowContext const&, clang::dataflow::TypeErasedDataflowAnalysis&, clang::dataflow::Environment const&, std::function<void (clang::CFGElement const&, clang::dataflow::TypeErasedDataflowAnalysisState const&)>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x1f48718)
 #8 0x0000aaaaab4d4a7c llvm::Expected<std::vector<std::optional<clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice> >, std::allocator<std::optional<clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice> > > > > clang::dataflow::runDataflowAnalysis<clang::dataflow::UncheckedOptionalAccessModel>(clang::dataflow::ControlFlowContext const&, clang::dataflow::UncheckedOptionalAccessModel&, clang::dataflow::Environment const&, std::function<void (clang::CFGElement const&, clang::dataflow::DataflowAnalysisState<clang::dataflow::UncheckedOptionalAccessModel::Lattice> const&)>) (/usr/lib/llvm-16/bin/clang-tidy+0x9c4a7c)
 #9 0x0000aaaaab4d4550 clang::tidy::bugprone::UncheckedOptionalAccessCheck::check(clang::ast_matchers::MatchFinder::MatchResult const&) (/usr/lib/llvm-16/bin/clang-tidy+0x9c4550)
#10 0x0000aaaaaba609c8 (/usr/lib/llvm-16/bin/clang-tidy+0xf509c8)
#11 0x0000aaaaaba901b0 clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches(clang::ast_matchers::internal::BoundNodesTreeBuilder::Visitor*) (/usr/lib/llvm-16/bin/clang-tidy+0xf801b0)
#12 0x0000aaaaaba6032c (/usr/lib/llvm-16/bin/clang-tidy+0xf5032c)
#13 0x0000aaaaaba62f08 (/usr/lib/llvm-16/bin/clang-tidy+0xf52f08)
#14 0x0000aaaaaba6bc48 (/usr/lib/llvm-16/bin/clang-tidy+0xf5bc48)
#15 0x0000aaaaaba635f8 (/usr/lib/llvm-16/bin/clang-tidy+0xf535f8)
#16 0x0000aaaaaba36ab4 clang::ast_matchers::MatchFinder::matchAST(clang::ASTContext&) (/usr/lib/llvm-16/bin/clang-tidy+0xf26ab4)
#17 0x0000ffff99a1d11c clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x268d11c)
#18 0x0000ffff97f586b8 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0xbc86b8)
#19 0x0000ffff999e8608 clang::FrontendAction::Execute() (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x2658608)
#20 0x0000ffff9997d904 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x25ed904)
#21 0x0000ffff99bdccd4 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284ccd4)
#22 0x0000aaaaabfa69ac (/usr/lib/llvm-16/bin/clang-tidy+0x14969ac)
#23 0x0000ffff99bdc9ac clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284c9ac)
#24 0x0000ffff99bdbb38 clang::tooling::ToolInvocation::run() (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284bb38)
#25 0x0000ffff99bddf58 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/lib/llvm-16/bin/../lib/libclang-cpp.so.16+0x284df58)
#26 0x0000aaaaabfa36a0 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-16/bin/clang-tidy+0x14936a0)
#27 0x0000aaaaab33e4cc clang::tidy::clangTidyMain(int, char const**) (/usr/lib/llvm-16/bin/clang-tidy+0x82e4cc)
#28 0x0000ffff8fff9e18 __libc_start_main (/lib/aarch64-linux-gnu/libc.so.6+0x20e18)
#29 0x0000aaaaab339ff8 _start (/usr/lib/llvm-16/bin/clang-tidy+0x829ff8)
Segmentation fault

I have tried rebuilding the dev container without cache, but the same issue persists.

PiotrZSL commented 5 months ago

Check with clang-tidy 18, as this issue most probably already is fixed.