<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112311>112311</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang][StaticAnalyzer] crash on imported CXXRecordDecl: clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1278: const clang::ento::CXXBaseObjectRegion *clang::ento::MemRegionManager::getCXXBaseObjectRegion(const clang::CXXRecordDecl *, const clang::ento::SubRegion *, bool): Assertion `isValidBaseClass(RD, cast<TypedValueRegion>(Super), IsVirtual)' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
danix800
</td>
</tr>
</table>
<pre>
Testcases:
```
export TEST_DIR=/tmp/test-crash
mkdir -pv $TEST_DIR
# test files:
cat > $TEST_DIR/Common.h << EOF
namespace { struct A; }
template<typename T>
struct Base {
void f() {}
};
struct Derived : public Base<A> {};
void foo();
EOF
cat > $TEST_DIR/Common.cpp << EOF
#include "Common.h"
void foo() {
Derived().f();
}
EOF
cat > $TEST_DIR/Test.cpp << EOF
#include "Common.h"
void bar() {
foo();
}
EOF
CTU_DIR=$TEST_DIR/ctu-dir/x86_64
mkdir -pv $CTU_DIR/ast$TEST_DIR
# test command:
clang $TEST_DIR/Common.cpp -emit-ast -o $CTU_DIR/ast$TEST_DIR/Common.cpp.ast
clang-extdef-mapping $TEST_DIR/Common.cpp -- | \
sed "s: $TEST_DIR/Common\.cpp$: ast$TEST_DIR/Common.cpp.ast:" \
> $CTU_DIR/externalDefMap.txt
clang-tidy $TEST_DIR/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- \
-Xclang -analyzer-config \
-Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=$CTU_DIR
```
Crash stacktrace:
```
clang-tidy: /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1278: const clang::ento::CXXBaseObjectRegion *clang::ento::MemRegionManager::getCXXBaseObjectRegion(const clang::CXXRecordDecl *, const clang::ento::SubRegion *, bool): Assertion `isValidBaseClass(RD, cast<TypedValueRegion>(Super), IsVirtual)' failed.
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 /tmp/test-crash/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=/tmp/test-crash/ctu-dir/x86_64
1. <eof> parser at end of file
2. While analyzing stack:
#0 Calling foo() at line 4
#1 Calling bar()
3. /tmp/test-crash/Common.cpp:4:3: Error evaluating statement
4. /tmp/test-crash/Common.cpp:4:3: Error evaluating statement
#0 0x00007f6c1e64ca7a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:723:11
#1 0x00007f6c1e64cc7b PrintStackTraceSignalHandler(void*) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:798:1
#2 0x00007f6c1e64af96 llvm::sys::RunSignalHandlers() /home/danis/Sources/llvm-project-main/llvm/lib/Support/Signals.cpp:105:5
#3 0x00007f6c1e64d495 SignalHandler(int) /home/danis/Sources/llvm-project-main/llvm/lib/Support/Unix/Signals.inc:413:1
#4 0x00007f6c1e05b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)
#5 0x00007f6c1e0a9e3c __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#6 0x00007f6c1e05afb2 raise ./signal/../sysdeps/posix/raise.c:27:6
#7 0x00007f6c1e045472 abort ./stdlib/abort.c:81:7
#8 0x00007f6c1e045395 _nl_load_domain ./intl/loadmsgcat.c:1177:9
#9 0x00007f6c1e053eb2 (/lib/x86_64-linux-gnu/libc.so.6+0x34eb2)
#10 0x00007f6c188eaa9f clang::ento::MemRegionManager::getCXXBaseObjectRegion(clang::CXXRecordDecl const*, clang::ento::SubRegion const*, bool) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/MemRegion.cpp:1281:9
#11 0x00007f6c189a9ba7 clang::ento::StoreManager::evalDerivedToBase(clang::ento::SVal, clang::QualType, bool) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/Store.cpp:296:20
#12 0x00007f6c189a9883 clang::ento::StoreManager::evalDerivedToBase(clang::ento::SVal, clang::CastExpr const*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/Store.cpp:261:14
#13 0x00007f6c188902d5 clang::ento::ExprEngine::VisitCast(clang::CastExpr const*, clang::Expr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngineC.cpp:424:33
#14 0x00007f6c18850243 clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:2287:7
#15 0x00007f6c1884c559 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:1135:9
#16 0x00007f6c1884c26d clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp:976:7
#17 0x00007f6c188112ff clang::ento::CoreEngine::HandlePostStmt(clang::CFGBlock const*, unsigned int, clang::ento::ExplodedNode*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:486:1
#18 0x00007f6c18810ac0 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:223:1
#19 0x00007f6c18810737 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>)::$_0::operator()(unsigned int) const /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:140:5
#20 0x00007f6c18810434 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Core/CoreEngine.cpp:163:29
#21 0x00007f6c18c4b604 clang::ento::ExprEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int) /home/danis/Sources/llvm-project-main/clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h:192:19
#22 0x00007f6c18bd2783 (anonymous namespace)::AnalysisConsumer::RunPathSensitiveChecks(clang::Decl*, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:729:7
#23 0x00007f6c18bd22ce (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:700:15
#24 0x00007f6c18b51168 (anonymous namespace)::AnalysisConsumer::HandleDeclsCallGraph(unsigned int) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:490:31
#25 0x00007f6c18b4fe16 (anonymous namespace)::AnalysisConsumer::runAnalysisOnTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:0:5
#26 0x00007f6c18b4f89e (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:613:3
#27 0x00007f6c180212b3 clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) /home/danis/Sources/llvm-project-main/clang/lib/Frontend/MultiplexConsumer.cpp:338:23
#28 0x00007f6c1090cee8 clang::ParseAST(clang::Sema&, bool, bool) /home/danis/Sources/llvm-project-main/clang/lib/Parse/ParseAST.cpp:191:12
#29 0x00007f6c17fd61f7 clang::ASTFrontendAction::ExecuteAction() /home/danis/Sources/llvm-project-main/clang/lib/Frontend/FrontendAction.cpp:1194:1
#30 0x00007f6c17fd5bec clang::FrontendAction::Execute() /home/danis/Sources/llvm-project-main/clang/lib/Frontend/FrontendAction.cpp:1082:7
#31 0x00007f6c17ec2636 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /home/danis/Sources/llvm-project-main/clang/lib/Frontend/CompilerInstance.cpp:1060:23
#32 0x00007f6c21410ae3 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:465:14
#33 0x00007f6c2152b789 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)::ActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/ClangTidy.cpp:581:37
#34 0x00007f6c2141097c clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:440:18
#35 0x00007f6c2140fa6d clang::tooling::ToolInvocation::run() /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:425:3
#36 0x00007f6c21411d6d clang::tooling::ClangTool::run(clang::tooling::ToolAction*) /home/danis/Sources/llvm-project-main/clang/lib/Tooling/Tooling.cpp:623:11
#37 0x00007f6c2152725c 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) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/ClangTidy.cpp:602:8
#38 0x00007f6c284a6a7d clang::tidy::clangTidyMain(int, char const**) /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:686:7
#39 0x00005558f17273c2 main /home/danis/Sources/llvm-project-main/clang-tools-extra/clang-tidy/tool/ClangTidyToolMain.cpp:20:3
#40 0x00007f6c1e04624a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#41 0x00007f6c1e046305 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007f6c1e046305 __libc_start_main ./csu/../csu/libc-start.c:347:5
#43 0x00005558f17272d1 _start (/home/danis/Sources/llvm-project-main/build/bin/clang-tidy+0x22d1)
./test.sh: line 44: 320417 Aborted clang-tidy $TEST_DIR/Test.cpp --checks=-*,clang-analyzer-core.DivideZero -- -Xclang -analyzer-config -Xclang experimental-enable-naive-ctu-analysis=true,ctu-dir=$CTU_DIR
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW99v27iT_2uYF8KGROrnQx4cOd5vgO01F3v7Le7FoCTa5lWiBJ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