[libcxx-commits] [libcxxabi] [libcxxabi] prevent __cxa_free_exception from being inlined when called in __cxa_decrement_exception_refcount (PR #222754)

via libcxx-commits libcxx-commits at lists.llvm.org
Fri Sep 11 07:25:33 PDT 2026


rickymolodiez wrote:

> Why would we want to support this? `__cxa_free_exception` isn't meant to be overridden, so this is incredibly fragile. Notably, we already have a fallback in case normal memory allocation fails.


The patch is not about fallback in case of failure, it is about being able to specify memory use for it. Let's say in an application that is tight on resources. It is possible to do something like for example overriding the default allocation function and build an interface like std::pmr::set_default_resource with that, but it is awkward to set/unset the default resource when it comes to exceptions, because their scope is so dynamic. As a concrete example, we can use it to break the execution of fibers without dynamic allocation. You can supply a preallocated buffer for the exception instead.

Also, libstdc++ supports it and people use it. There is stackoverflow threads about people using it and getting it to work with libstdc++.

It's an extremely niche situation but it can come up


https://github.com/llvm/llvm-project/pull/222754


More information about the libcxx-commits mailing list