[Bug libstdc++/68606] Reduce or disable the static emergency pool for C++ exceptions

dumoulin.thibaut at gmail dot com gcc-bugzilla@gcc.gnu.org
Wed Sep 28 14:42:42 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68606

--- Comment #12 from Thibaut M. <dumoulin.thibaut at gmail dot com> ---
Thank you for the updated link!

The problem with the original code is that it malloc unconditionally at least
2.4ko on the heap. This cannot be avoided when liking with libstdc++.
This malloc is done very early, when initializing `.init_array` section (in
ResetHandler on an ARM Cortex M for example).

As 2.4ko is a lot for some embedded systems, it would be nice to avoid this
behavior.
Also, even if this code is never used in your project, none of the symbols in
eh_malloc.cc are called; the constructor of the global variable `pool
emergency_pool;` calls a non-pure functions, compiler cannot get rid of this
function.

If you do not use this code in your project, it will cost you, unconditionally,
2.4ko of heap.
This is the problem.

This patch https://gcc.gnu.org/legacy-ml/gcc-patches/2016-12/msg01158.html
seems a nice solution, it allocates a static buffer and if nobody is using it,
it can be stripped by the linker.


More information about the Gcc-bugs mailing list