Re: cannot longjmp from g_log_set_handler function




Andrew Thomas <andrew@cogent.ca> writes:

> I created an error handler using g_log_set_handler that calls the
> error handler for a language interpreter.  The action of the
> interpreter is to throw an error, which entails a longjmp.  The
> next time an error occurs in a GTK+ function, the error handler
> enters again, where a global flag in the log routines says that
> the second entry is a recursion (falsely), due to some code that
> sets a global flag in the g_ error handler but never clears it on
> a longjmp.
> 
> I suggest that there needs to be a function that will clean up
> the error handler context in the event of a longjmp, so that it
> is possible to throw GTK+ errors.  At the moment, the g_log_
> function is only good for aborting a run, not for recovery.

Yep.

I'm not at all sure if I like the idea of somebody 
long-jumping out of a g_error()

 - 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+

g_error indicates fatal errors. 

                                        Owen

P.S. - yes, exception handling is nice; but the only
way to do it safely in C, IMO,  is to make all functions
take another parameter, and you'll end up easily
doubling the length and complexity of your code if
you do that.



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