On Jan 18, 2006, at 9:41 AM, 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.
You'll want to read the code. Last I knew, there was a fallback buffer that is used to allocate from when malloc fails, just so you can throw on memory failure. You can retune to have any size fallback buffer you want, but once it is gone, you die.
Also, be sure to throw and catch one exception up front if you care deeply about things working well. This preallocates things and gets things hot so that the chances of dying later are reduced.
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 was good, with some luck, it still is.
It seems like a better approach would be to pre-allocate storage and use it during the exception handling.
No need to use the preallocated area if malloc is going to work for you.
Has this been considered?
Yes.