<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/58289>58289</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
ItaniumDemangler presumes allocator success
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
urnathan
</td>
</tr>
</table>
<pre>
libcxxabi/src/demangle/ItaniumDemangle.h contains several instances of placement new:
```
void *mem = ASTAllocator.allocateNodeArray(sz);
Node **data = new (mem) Node *[sz];
```
These presume the allocator never returns nullptr. I.e. always succeeds or throws. That's in conflict with the itanum abi library requirements, which have the demangler return an error code on memory exhastion. We don't do that, instead calling std::terminate on failure. But it would be good to be able to move to a more compliant demangler.
You'll notice the demangler's node allocator has smarts to check for nullptr.
We can't use exceptions here either, as (IIUC), the demangler should not require the unwinder. And besides we don;t have an outer catch to turn that exception into an error code.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxdU8lu2zAQ_RrpMqggU14POjgxDOTSS1MUPVLU2GJLkS4XO-nX91GOEzcAQY24zLxl2Ln-tTW6Uy8vstOF2AevMPc8Sns0jPApSqvTuHtbqQZSzkapbaDAZ_bSEGIcUhzIHehkpOKRbSTLl6LZFvWuqLfFsn4b0y8RnZ3uqRDbkUcqmh1tvz1vjXFKRucreY34q-t56718LcQ6_C3Epmge3jNQ3s0pMHoZ5ZQGRbG0Rlac_jixeMD1xe79-ic81_l54MB08hzSyBQHJnlDhLzgSp5j8mBukzGn6Cuip4orHLvIV-iRlGLuIYPHbe8uAQeeBxkLsQpQKSt3MFpFuug4TAU0hEsjQXuCC176V9T4k7SfJAyFeKTLoNVAgzxfId2suYEhaYm9R0mVyTpL4O6Qh18GGaJ2FiB-4J6zgBHxRZoM6XHyjWVPCjS1PVKIfTas2Ub2o7bQP6c7SG2SB0t6SBGA6eKS6aljOjrXU3Q5lJ3hHI7uPH0lIs-ANJ6MlmiGd9jVveI_XQIoY8i6qNUngpNqNpP6sAGUKIzSx5CrqIHVbzpke94MuU8O0kpeSSf4yi-KT1mPQAMDG8ODXOSRkBMt8_T0_TF3GBb-1zkME2FAvHkzHUj2om3PuQm2NusRdI8ncLlK3TzEq2ewxyUICiwRPgL15Fr24AMSrMii3TtZldzOlsvFfNOIuSj7tuk3zUaWUUfD7adX6W9dG-60mtoxhDJ50w4xnkI2V-wxjqCeugru4MeY8-3z5eTdL1Zojr0OITH6b79Yi_WmHFq5mrNcLNczyRvM60YdAK2Zi81arJrZqjSyYxNaPLVCiPwMpxSI8e5K3YpaiFk9m82aum7qajXfLOtDVy8Wh7rmui_mNbhoU2UclfPH0rcTpC4dAzaNDjF8bMoQ9NEyT-WQX6Y4ON9CWQllbTnVbifs_wAEnZ_l">