<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/94526>94526</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Bug] Crash when building `libpqxx` with `clang-tidy-18`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang-tidy
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
michaelghaben-presto
</td>
</tr>
</table>
<pre>
A segfault was encountered while running `clang-tidy-18` to build [`libpqxx`](https://github.com/jtv/libpqxx). The error requested for a pug report to be submitted at this repo. The stack trace is as follows:
```
Error running 'clang-tidy-18': 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-18 --extra-arg-before=--driver-mode=g++ /home/michael/workspace/presto2/build/_deps/libpqxx-src/test/unit/test_range.cxx -- /usr/bin/clang++-18 -I/usr/include/postgresql -I/home/michael/workspace/presto2/build/_deps/libpqxx-build/include -I/home/michael/workspace/presto2/build/_deps/libpqxx-src/include -std=c++20 -MD -MT _deps/libpqxx-build/test/CMakeFiles/runner.dir/unit/test_range.cxx.o -MF CMakeFiles/runner.dir/unit/test_range.cxx.o.d -o CMakeFiles/runner.dir/unit/test_range.cxx.o -c /home/michael/workspace/presto2/build/_deps/libpqxx-src/test/unit/test_range.cxx
1. <eof> parser at end of file
2. While analyzing stack:
#0 Calling (anonymous namespace)::test_range_intersection()
3. /home/michael/workspace/presto2/build/_deps/libpqxx-src/test/unit/test_range.cxx:513:37: Error evaluating statement
4. /home/michael/workspace/presto2/build/_deps/libpqxx-src/test/unit/test_range.cxx:513:37: Error evaluating statement
#0 0x00007ff336b9f8b6 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9f8b6)
#1 0x00007ff336b9d8e0 llvm::sys::RunSignalHandlers() (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9d8e0)
#2 0x00007ff336b9ff7b (/usr/lib/llvm-18/bin/../lib/libLLVM.so.18.1+0xd9ff7b)
#3 0x00007ff335c5b050 (/lib/x86_64-linux-gnu/libc.so.6+0x3c050)
#4 0x00007ff3402b3de2 clang::ento::MemRegionManager::getVarRegion(clang::VarDecl const*, clang::LocationContext const*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2cb3de2)
#5 0x00007ff3402e545a (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2ce545a)
#6 0x00007ff340294859 clang::ento::ExprEngine::handleConstructor(clang::Expr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2c94859)
#7 0x00007ff340277f8e clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2c77f8e)
#8 0x00007ff340275863 clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2c75863)
#9 0x00007ff34027558f clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2c7558f)
#10 0x00007ff34025c617 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2c5c617)
#11 0x00007ff34025c181 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2c5c181)
#12 0x00007ff34067e355 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x307e355)
#13 0x00007ff34065e3b4 (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x305e3b4)
#14 0x00007ff33fff030c clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x29f030c)
#15 0x00007ff33e183636 clang::ParseAST(clang::Sema&, bool, bool) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0xb83636)
#16 0x00007ff33ffb42f5 clang::FrontendAction::Execute() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x29b42f5)
#17 0x00007ff33ff2b044 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x292b044)
#18 0x00007ff3401a3561 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2ba3561)
#19 0x0000556b1f820301 (/usr/lib/llvm-18/bin/clang-tidy+0x1363301)
#20 0x00007ff3401a32df clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2ba32df)
#21 0x00007ff3401a2174 clang::tooling::ToolInvocation::run() (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2ba2174)
#22 0x00007ff3401a51a5 clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/usr/lib/llvm-18/bin/../lib/libclang-cpp.so.18.1+0x2ba51a5)
#23 0x0000556b1f81c497 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-18/bin/clang-tidy+0x135f497)
#24 0x0000556b1ebb8eaf clang::tidy::clangTidyMain(int, char const**) (/usr/lib/llvm-18/bin/clang-tidy+0x6fbeaf)
#25 0x00007ff335c4624a __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#26 0x00007ff335c46305 call_init ./csu/../csu/libc-start.c:128:20
#27 0x00007ff335c46305 __libc_start_main ./csu/../csu/libc-start.c:347:5
#28 0x0000556b1ebb4271 _start (/usr/lib/llvm-18/bin/clang-tidy+0x6f7271)
Segmentation fault
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzUWV9v4zYS_zTMC2FDIvXPD3lwnPi6wOYabNLto0FJI5ldmnRJKnHu0x9Iybbo2m12axR3i2ATieTMb37zh0ORGcNbCXCL0juU3t-wzq6Vvt3was1AtGtWgpxsNRirbkpVv9_OsYG2YZ2w-I0ZDLJSnbSgocZvay4A605KLluMsqgSTLYTy-v3SVygLMJW4bLjosZOWxYJXm5_3-1QFqH0HpFibe3WIDpHZInIsuV23ZXTSm0QWf5mXxFZ7heQ2RS_rAGD1kpjDb93YCzUuFEaM7ztWqxhq7T1CgGbrtxw6yYwi-2aGz_cizCWVd-w1awCzA1mBjdKCPXmcUT3KJo7eP1P_-j_f-g1720leWgryRGd46fPD_Pnh0E9ZrgMgP2JtUK87n9Ntlr9BpVFZMmN6cAgssRM1pjLSnQ1YLsGXGlm1rhk1TdvyLTH-OxNq7vN9mBLNMX-35NWrWYbzHTbbUBahwMHJuDJBHZWswnT7aSERmlA9H4yqTV_BT3ZqNo9t4jcIXKHEVmu1QYQWQ6Rg8jyTelvZssq97aPIILI0vsfkeWqhq05unRidIXI0oJxlnaS2-FppZlsYVrtdngycXo6o50YLhFZesQ9BA_502F8YMepVsa2Gszvoh__mzj37_f0X0Nmb_tBorE1ov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