Re: cannot longjmp from g_log_set_handler function




Lars Hallberg <lah@micropp.se> writes:

> On Sun, Mar 28, 1999 at 10:54:48PM +0900, Ionutz Borcoman wrote:
> > On 27 Mar 1999, Owen Taylor wrote (about longjumps):
> > >
> > >  - You will almost certainly leak memory.
> > 
> > >  - You may well leave GTK+ in an inconsistent state
> > >    that and may well get segfaults if you continue
> > >    using GTK+
> > 
> > Are exceptions safe to use from C++ (with try() ... throw() ... catch())
> > ? 
> 
> As GTK+ is a C library it can't be exeption safe. C++ exeption cleans
> up by unwinding the stack and call the destructor for all auto objects
> that goes out of scoop. C hav no such featurs! You have to wrapp all
> GTK resorses into C++ classes that cleans up on destruction to make
> Your code exeption safe.

To nitpack, a (simple) C library could be exception
safe it did all allocation on the stack and kept no state
over callbacks. But GTK+ is very definitely not even close 
to exception safe. 

(And not just with leaking memory... a lot code in GTK+ assumes 
that after you call a callback, it will get control back)
 
Making even a C++ library exception safe is fairly difficult
because it is adding a lot of code paths to ones code that
are going to be tested only in exceptional situations.

Regards,
                                        Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]