Cancellation while throwing exception

Scott Lamb slamb@slamb.org
Sun Jan 25 19:19:00 GMT 2004


I was just reading a document that claims C++ code should never throw 
exceptions in destructors, because Bad Things could happen if one is 
throwing while unwinding the stack due to another exception - you can't 
have two simultaneous active exceptions, so either std::unexpected() 
gets called, or maybe std::terminate() directly (don't remember exactly).

It occurred to me that under NPTL, this is essentially the same as 
cancellation while throwing an exception. The attached test program 
shows that indeed std::terminate() gets called.

Maybe cancellation should be disabled for the duration of exception 
throwing?

Thanks,
Scott Lamb
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: test_cancellation_while_throwing.cc
URL: <http://sourceware.org/pipermail/libc-alpha/attachments/20040125/05a1e01f/attachment.cc>


More information about the Libc-alpha mailing list