This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: [RFA] exceptions.h: Fix definition of TRY_CATCH
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sources dot redhat dot com
- Date: Wed, 9 Mar 2005 12:40:15 -0500
- Subject: Re: [RFA] exceptions.h: Fix definition of TRY_CATCH
- References: <20050309164803.GN2839@cygbert.vinschen.de>
On Wed, Mar 09, 2005 at 05:48:03PM +0100, Corinna Vinschen wrote:
> If you inspect it, you'll see that the first parameter `env' is evaluated
> three times. Since the first parameter is a call to the function
> exceptions_state_mc_init(), the result is that three new catcher structures
> are created. But only one of them, the last one which has been created,
> is correctly iniitialized by the call to exceptions_state_mc_action_iter().
> I guess you see what will happen at one point. A non-initialized catcher
> is current when the function exceptions_state_mc_action_iter_1() is called
> ==> internal_error.
>
> Note that this is *not* a flaw in newlib or Cygwin. It's perfectly fine
> that setjmp and sigsetjmp are defined as macros as above, see
> http://www.opengroup.org/onlinepubs/009695399/functions/setjmp.html and
> http://www.opengroup.org/onlinepubs/009695399/functions/sigsetjmp.html,
> so the usual macro expansion restrictions apply.
>
> Conclusion: The actual problem is that the sigjmp_buf is created in a
> function call which is the first parameter to sigsetjmp.
Nice catch!
> Solution: Don't do it. :-)
>
> A patch is below. Tested on Cygwin and Linux.
>
>
> Ok to check in?
>
>
> Corinna
>
>
> * exceptions.h (TRY_CATCH): Define setjmp/sigsetjmp macro save.
Yes, this is OK (save -> safe in the changelog).
--
Daniel Jacobowitz
CodeSourcery, LLC