This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Calls to malloc during an exception
- From: "H. J. Lu" <hjl at lucon dot org>
- To: Perry Smith <pedz at easesoftware dot net>
- Cc: GCC Development <gcc at gcc dot gnu dot org>
- Date: Wed, 18 Jan 2006 09:54:37 -0800
- Subject: Re: Calls to malloc during an exception
- References: <CEE3015A-6958-4D8E-970C-E4C1164BA72F@easesoftware.net>
On Wed, Jan 18, 2006 at 11:41:39AM -0600, Perry Smith wrote:
> In the course of doing my work last week to get exception handling
> working in my device driver, I learned that the exception processing
> code calls malloc during the exception. This seems weak to me. It
> seems like one of the most critical times to throw an exception is
> when malloc fails.
>
> I did not study the code very much to see what happens if the malloc
> fails during the exception processing but I assume its not good.
>
> It seems like a better approach would be to pre-allocate storage and
> use it during the exception handling. The design objective, to me,
> would be to make the exception handling as bullet proof as possible.
> I understand that it is not known how many exceptions are going to
> stack up but I think taking a reasonable guess, pre-allocating that
> space, and then fall back to malloc when that space fills up would be
> much less likely to fail during a critical time.
>
> Has this been considered?
It is a major flaw in the gcc exception handling. I'd like to see it
get fixed.
H.J.