Boost logo

Boost :

Subject: Re: [boost] Question for C++ experts about exception allocationfailure
From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2009-05-17 06:19:51

Adam Badura wrote:
>> GCC allocates exceptions on the heap. If that fails, it will allocate
>> them in the emergency storage instead. The emergency storage is a small
>> MSVC allocates on the stack.
> I am a bit surprised. During compilation it can be checked what is
> the maximal size of exception being thrown and preallocate space for
> it (or maybe two such to handle throwing from within catch).
First, the analysis to get the total size of all exceptions that could
be active at the same time requires the dynamic call stack. This
includes dynamic libraries. It is therefore fundamentally impossible to
correctly determine this size.
Second, when threading is in play, you must multiply this amount by the
maximum number of threads ever active concurrently. This is just as
Third, when you have exception propagation, you can keep exceptions
alive indefinitely. In theory, you could end every single catch block
you have by pushing current_exception() into a global container. Thus,
over the run time of the application you can accumulate an arbitrary
amount of exceptions.

So no, you can't statically determine the size you need.


Boost list run by bdawes at, gregod at, cpdaniel at, john at