Re: Hang in throw
James Kanze wrote:
- You exception could be uncaught. In this case the runtime
will abort your program.
Which isn't the same as hanging.
If it succeeds. The on exit handlers of your application could still
hang. Even the ones of the C-runtime.
However, there are places, where this is unwise, because you
are currently executing a callback from the runtime, e.g. a
signal handler.
Throwing an exception from a signal handler isn't allowed, and
may not work. Or it may work most of the time, but not always.
(It's undefined behavior.)
That's what I mean. So you have to be very careful since many runtime
functions may throw unhandled exceptions.
- You may have corrupted the free space arena previously, which
causes the code to hang when constructing the string for the
exception. In fact, any previous undefined behavior can lead to
this sort of problem. But corrupting the free space arena seems
most common.
I had almost no heap corruption in the last years. Since I consequently
switched to C++ strings, smart pointers and smart array pointers or STL
containers, the problem has gone. In case of the smart array pointers I
use only implementations that keep track of the size.
Marcel