<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/64647>64647</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [clang static-analyzer] crash with clang-analyzer-optin.mpi.MPI-Checker on MPI_Wait
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          5chmidti
      </td>
    </tr>
</table>

<pre>
    ```c++
#include "mpi.h"
bool contains();
void do_a() {
        if (contains()) {
                MPI_Request request_item;
                MPI_Wait(&request_item, MPI_STATUS_IGNORE);
        }
        do_a();
}
```

<details>
<summary>backtrace</summary>

```text
Stack dump:
0.      Program arguments: clang-tidy -checks=-*,clang-analyzer-optin.mpi.MPI-Checker -p . NetworkMotifs.cpp
1.      <eof> parser at end of file
2.      While analyzing stack: 
        #0 Calling do_a() at line 8
        #1 Calling do_a()
3.      /path/to/file.cpp:6:3: Error evaluating statement
4.      /path/to/file.cpp:6:3: Error evaluating statement
 #0 0x0000564f85e12198 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/user/install/llvm-project/bin/clang-tidy+0x17b5198)
 #1 0x0000564f85e100d0 llvm::sys::RunSignalHandlers() (/home/user/install/llvm-project/bin/clang-tidy+0x17b30d0)
 #2 0x0000564f85e12b48 SignalHandler(int) Signals.cpp:0:0
 #3 0x00007f59c323e710 (/usr/lib/libc.so.6+0x3e710)
 #4 0x0000564f86f23197 clang::ento::mpi::MPIChecker::checkUnmatchedWaits(clang::ento::CallEvent const&, clang::ento::CheckerContext&) const (/home/user/install/llvm-project/bin/clang-tidy+0x28c6197)
 #5 0x0000564f86f26304 void clang::ento::check::PreCall::_checkCall<clang::ento::mpi::MPIChecker>(void*, clang::ento::CallEvent const&, clang::ento::CheckerContext&) MPIChecker.cpp:0:0
 #6 0x0000564f871126c9 clang::ento::CheckerManager::runCheckersForCallEvent(bool, clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNodeSet const&, clang::ento::CallEvent const&, clang::ento::ExprEngine&, bool) (/home/user/install/llvm-project/bin/clang-tidy+0x2ab56c9)
 #7 0x0000564f87162040 clang::ento::ExprEngine::evalCall(clang::ento::ExplodedNodeSet&, clang::ento::ExplodedNode*, clang::ento::CallEvent const&) (/home/user/install/llvm-project/bin/clang-tidy+0x2b05040)
 #8 0x0000564f87161e65 clang::ento::ExprEngine::VisitCallExpr(clang::CallExpr const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/home/user/install/llvm-project/bin/clang-tidy+0x2b04e65)
 #9 0x0000564f8713f11e clang::ento::ExprEngine::Visit(clang::Stmt const*, clang::ento::ExplodedNode*, clang::ento::ExplodedNodeSet&) (/home/user/install/llvm-project/bin/clang-tidy+0x2ae211e)
#10 0x0000564f8713b4aa clang::ento::ExprEngine::ProcessStmt(clang::Stmt const*, clang::ento::ExplodedNode*) (/home/user/install/llvm-project/bin/clang-tidy+0x2ade4aa)
#11 0x0000564f8713b1f4 clang::ento::ExprEngine::processCFGElement(clang::CFGElement, clang::ento::ExplodedNode*, unsigned int, clang::ento::NodeBuilderContext*) (/home/user/install/llvm-project/bin/clang-tidy+0x2ade1f4)
#12 0x0000564f8711c364 clang::ento::CoreEngine::dispatchWorkItem(clang::ento::ExplodedNode*, clang::ProgramPoint, clang::ento::WorkListUnit const&) (/home/user/install/llvm-project/bin/clang-tidy+0x2abf364)
#13 0x0000564f8711bf58 clang::ento::CoreEngine::ExecuteWorkList(clang::LocationContext const*, unsigned int, llvm::IntrusiveRefCntPtr<clang::ento::ProgramState const>) (/home/user/install/llvm-project/bin/clang-tidy+0x2abef58)
#14 0x0000564f86d21c06 (anonymous namespace)::AnalysisConsumer::HandleCode(clang::Decl*, unsigned int, clang::ento::ExprEngine::InliningModes, llvm::DenseSet<clang::Decl const*, llvm::DenseMapInfo<clang::Decl const*, void>>*) AnalysisConsumer.cpp:0:0
#15 0x0000564f86d01623 (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) AnalysisConsumer.cpp:0:0
#16 0x0000564f8744895c clang::MultiplexConsumer::HandleTranslationUnit(clang::ASTContext&) (/home/user/install/llvm-project/bin/clang-tidy+0x2deb95c)
#17 0x0000564f8764b5f6 clang::ParseAST(clang::Sema&, bool, bool) (/home/user/install/llvm-project/bin/clang-tidy+0x2fee5f6)
#18 0x0000564f873ccf17 clang::FrontendAction::Execute() (/home/user/install/llvm-project/bin/clang-tidy+0x2d6ff17)
#19 0x0000564f8733ed64 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/home/user/install/llvm-project/bin/clang-tidy+0x2ce1d64)
#20 0x0000564f85e93404 clang::tooling::FrontendActionFactory::runInvocation(std::shared_ptr<clang::CompilerInvocation>, clang::FileManager*, std::shared_ptr<clang::PCHContainerOperations>, clang::DiagnosticConsumer*) (/home/user/install/llvm-project/bin/clang-tidy+0x1836404)
#21 0x0000564f85ef7d3e 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*) ClangTidy.cpp:0:0
#22 0x0000564f85e93196 clang::tooling::ToolInvocation::runInvocation(char const*, clang::driver::Compilation*, std::shared_ptr<clang::CompilerInvocation>, std::shared_ptr<clang::PCHContainerOperations>) (/home/user/install/llvm-project/bin/clang-tidy+0x1836196)
#23 0x0000564f85e91c5b clang::tooling::ToolInvocation::run() (/home/user/install/llvm-project/bin/clang-tidy+0x1834c5b)
#24 0x0000564f85e94aef clang::tooling::ClangTool::run(clang::tooling::ToolAction*) (/home/user/install/llvm-project/bin/clang-tidy+0x1837aef)
#25 0x0000564f85ef2f77 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/user/install/llvm-project/bin/clang-tidy+0x1895f77)
#26 0x0000564f85ddda6d clang::tidy::clangTidyMain(int, char const**) (/home/user/install/llvm-project/bin/clang-tidy+0x1780a6d)
#27 0x00007f59c3227cd0 (/usr/lib/libc.so.6+0x27cd0)
#28 0x00007f59c3227d8a __libc_start_main (/usr/lib/libc.so.6+0x27d8a)
#29 0x0000564f85dd8a55 _start (/home/user/install/llvm-project/bin/clang-tidy+0x177ba55)
fish: Job 1, 'clang-tidy -checks='-*,clang-an…' terminated by signal SIGSEGV (Address boundary error)
```
</details>

Invocation: `clang-tidy -checks='-*,clang-analyzer-optin.mpi.MPI-Checker' -p . <file>`
LLVM version: bd686ca4f7a0
Godbolt: https://godbolt.org/z/39P7W6KPa
Note that compiler-explorer does not have mpi.h, so I provided the necessary symbols myself.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWt1yGysSfhp8Q9k1A_N74QtFlnK8G-e4Ip-TSxUDjMRmBrSAFOs8_RbM6IexFCsbVW3t1rocRxqa5uuvm6aBIcaIheT8HqQfQPpwQ9Z2qfR9SpetYFbcVIpt70EWdb8UoA_uN3oA0QggLCRt1oxDgFC7EndLgFDXVinVQKqkJUIagAqASoD7fhslGGRqTrrnEOQ7hVEpaghQMeg4kAFR-fT8OP_C_7nmxkLd_T8Xlrf7MQ5iX4mwXk8WCKIxdK2zl9HLH7P548fPv3-ZHIN0CvKH_ecD3IPEvnnHzk7a_8Vjxi0RjQF4sn9k1m1L9BbgSUXoN6sJ5QCPAZoeGgIlO82Wv9ru0cwS-g2ydbsCuJeK7qD_edZqoUkLiV6sWy6tAXgE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