This is the mail archive of the gdb-patches@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [RFC] sigsetjmp/siglongjmp on cygwin -- problem tracked down


On Mon, Aug 13, 2001 at 07:32:25PM -0400, Christopher Faylor wrote:
>On inspection of cygwin's code, I don't understand how this could be a cygwin
>bug.  I've been meaning to investigate this.
>
>I'll do it right now.
>
>In the meantime, I think that configury changes are premature.

Well, on further inspection of "cygwin"'s code, I found the problem.

The fact that this worked on NT was just pure providence.  It probably
accounts for random crashes that I've been seeing.

The problem is that siglongjmp and sigsetjmp are implemented as macros:

define sigsetjmp(env, savemask) (env[_SAVEMASK] = savemask,\
               sigprocmask (SIG_SETMASK, 0, (sigset_t *) &env[_SIGMASK]),\
               setjmp (env))

#define siglongjmp(env, val) (((env[_SAVEMASK])?\
               sigprocmask (SIG_SETMASK, (sigset_t *) &env[_SIGMASK], 0):0),\
               longjmp (env, val))

If you look at the use of env, you can see that it is unprotected.  It should
have parentheses around it.

The failing line in gdb is this:

(NORETURN void) SIGLONGJMP (*catch_return, (int) reason);

So, with the above buggy code, we'll eventually derefernce *catch_return[36]
when we should be dereferencing (*catch_return)[36].

I'll fix cygwin.  How do we want to fix gdb?

I could add a define in setjmp.h like this:

#define WORKING_SETJMP 1

and gdb could test for this, implementing a known working version of
sig{set,long}jmp for this case.

That's kind of kludgy but it would guarantee that we provide a working
version of these functions for cygwin.

Or, we could just default to longjmp/setjmp in cases where this optimistic
define is not present.

I'm open to doing it however people prefer.  I will change cygwin so that
this is not a problem regardless.

Thanks Keith for bringing this to light.  This is a long-standing
cygwin/newlib bug.

cgf


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]