Re: Hang in throw
Hi,
jarek wrote:
I have strange problem - program hangs on calling throw. The program is
quite simple, so I don't this that source code with tell something.
The question is: how to debug it? The same throw called from other
places works fine. But from one hangs program.
Debian Lenny, gcc 4.3.2
There is a class:
class Exception : public exception {
[...]
And in some place of code there is:
throw Exception("Command failed!");
In some cases program hangs on this throw statement.
What can be the reason ?
you certainly provided only the unimportant part of the information.
It is essential where you throw an exception!
- You exception could be uncaught. In this case the runtime will abort
your program. However, there are places, where this is unwise, because
you are currently executing a callback from the runtime, e.g. a signal
handler.
- Your exception could be caught, but that causes a deadlock, because
you threw the exception while holding a mutex. With a non-recursive
mutex this may even happen with a single thread.
- You application code might not be exception safe because of code
fragments with undefined behavior in case of exceptions.
Marcel