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

    <tr>
        <th>Summary</th>
        <td>
            LLDB crashes on incorrect MSVC C++ ABI debug info
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            lldb,
            platform:windows
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          mstorsjo
      </td>
    </tr>
</table>

<pre>
    C++ code on Windows can either be using the MSVC C++ ABI, or the Itanium ABI (in mingw mode). Since 25c8a061c5739677d2fc0af29a8cc9520207b923 and 3c867898c7be7ed2b5d119a2478a836a0c85f19b, it's possible to set the desired ABI mode when using LLDB. But for cases when running in the wrong mode, LLDB can flat out crash (triggers a failed assert) for some C++ code.

This is reproducible with the attached testcase [cxxabi.zip](https://github.com/llvm/llvm-project/files/9078034/cxxabi.zip).
 
To reproduce (which can be done on any OS, doesn't need to actually run on Windows):
```
$ lldb cxxabi.exe
(lldb) target create "cxxabi.exe"
Current executable set to '/home/martin/test/cxxabi.exe' (x86_64).
(lldb) l callFunc
Assertion failed: (IA && "Expected MSInheritanceAttr on the CXXRecordDecl!"), function getMSInheritanceModel, file /home/martin/code/llvm-project/clang/lib/AST/MicrosoftCXXABI.cpp, line 236. 
```

(Here, the issue is avoidable e.g. by starting lldb with `lldb -O "settings set plugin.object-file.pe-coff.abi gnu" cxxabi.exe`.)

CC @ZequanWu @alvinhochun @rnk @zmodem 

I'm not sure exactly at what point this should be fixed - I guess it's somewhat acceptable for Clang, running in MSVC mode, to use such assertions - but when the input isn't from Clang itself but from debug info read by LLDB, some more error checks at some point seems to be needed.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyVVcuO2zYU_Rp5czGCTFmvhRceTwcdIIMAnaAJuikoipKYUKRKUmNPvr73UnbGbbMpQFDi6_Kc-zhsbfe2PybsHhsI20mwBj4r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