<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61945>61945</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Abort in cleanup leads to
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nikic
</td>
</tr>
</table>
<pre>
Consider the following example:
```cpp
#include <cstdlib>
#include <cstdio>
struct Abort {
~Abort() {
puts("cleanup");
abort();
}
};
__attribute__((noinline))
static void abort_in_dtor() {
Abort abort;
throw "test";
}
int main() {
try {
abort_in_dtor();
} catch (...) {
puts("caught");
}
}
```
This should print "cleanup" followed by abort. Instead this happens when using Clang 17:
```
terminate called after throwing an instance of 'char const*'
Aborted (core dumped)
```
The reason for this is that we now (correctly) infer that abort_in_dtor() is nounwind. However, as phase 1 unwind skips cleanups, this means that the unwind walk will try to go past a nounwind frame, which may not have an LSDA entry, resulting in some form of unwinding failure. (In this specific case we return _URC_END_OF_STACK, but a similar case in Rust results in _URC_FATAL_PHASE1_ERROR.)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2P4zYM_TXKhVjDkfPhHHzIJhPsootuMTM9G7TExOrIkiHR4-bS317Izs5HZ7uAIUOkSD4-PgljNBdHVIn1Z7E-LnDg1ofKmSejFo3X1-rgXTSaAnBLcPbW-tG4C9Df2PWWRLEX-VHke7HJ50_1_c0iC-OUHTSBKA4qsramEcXd_3mNf3VOa-QwKIZ94wOD2H6erQD_TBYhSyF3b-0A_cBxsktlCd3QCymF3InizRl8DX61i-3xVnl7fLHOa10jczDNwFTXU1zpvHHWOEop5O4HWGSj4NkbPZeojas1-_AB59zPDOMVGLfBjyCkZIqcYL-geIE2rcYxdGjcx_Y5XN9sf4LhTTWxPYJCVi0IWWZZ9ismcbi0_F8i3xH2XgDz9rE1EWLrB6uhDwn1u6nclEQamuuMNYOvLjKhBk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