Calls to malloc during an exception
H. J. Lu
hjl@lucon.org
Wed Jan 18 17:54:00 GMT 2006
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.
More information about the Gcc
mailing list