<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/85281>85281</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
SIGSEGV under DenseMapBase::erase after std::bad_alloc
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cuviper
</td>
</tr>
</table>
<pre>
Ref: https://github.com/rust-lang/rust/issues/121305
In that Rust issue, running on an `i686` host, I found that `DenseMap::allocateBuckets` -> `llvm::allocate_buffer` -> `operator new` was throwing `std::bad_alloc`. Then when unwinding runs the destructors into `LLVMContextDispose`, we get back into `DenseMapBase::erase` and hit `SIGSEGV`, presumably in the same instance that failed allocation.
Maybe `allocate_buffer` should catch and call `report_bad_alloc_error` like the `safe_*alloc` functions do? But even so, it seems that some part of `DenseMap` is not exception safe.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U09v-jgU_DTO5Qnk2EmAQw5QfvxUqb20q16R47wQb40d-dml_fYrB9pttX8uBkUz43njeYrInBxiy-odq_eFSnH0odXpzUwYis73H-0TDkxuYYxxIia3TByYOJxMHFO31P7MxCEkigur3On2n4mDIUpITBxKUUpeM75nfHs97x3EUUV4ShRhxjFxByE5Z9wJvAPlgDXcNOuGNRxGnwXv4B4Gn1x_5bKG79ERPqopW5JbZa3XKuIu6VeMlIkLJn9loLVv55-gY5eGAcN3kJ8wqOgDOLzk7xdFEMfgL9kTazjF_qrRqf4467CGL-GPER1c8pHcxbg-o0NymYvQI8WQdPSBwLjos87Dw8vjnXcR3-Pe0OQJWcPzeBeEE0bolH79An-OuFOE19sxqJkByvUwmjmI5_vfz79-v9x0poCUzqqzH2DcbIPUGcE4isppvMY3KGOxh1sexrvl9wd6VB8dZuV_yYtGn2wPWkU9zia0sjZjA04-xONXPEcMwc8Ua15xNpJjVAMemdh-JghDcjobIOg9kwfYpQj4hg7I52lMBEI809U2-TPCpEIEP_yoQMPBEDgfAd81TlkQ8lXLom9lv5EbVWBbrkpeyQ2Xshhbvq51t1nXWOthqFZlt6lLvqkHgX1XadkUphVcVFyWVbmqV6VcCtmsq7rXtRIDdnLDKo5nZewy92vpw6mYu9yua7EuC6s6tDSvlRAOL59FF3nLQps5iy6diFXcGor0t0o00WJ7e1RIrscA_1EEUEPEAP_sZpGCbf9nYeeVuP4spuD_RP1jZ-cR_goAAP__l19Uag">