On Apr 3 13:18, Corinna Vinschen wrote: > On Apr 2 20:30, Jon TURNEY wrote: > > * exceptions.cc (call_signal_handler): Only bother to construct > > the ucontext for signal handlers with SA_SIGINFO set. > > Looks good, except... > > > + ucontext_t context; > > + ucontext_t *thiscontext = NULL; > > + > > + /* Only make a context for SA_SIGINFO handlers */ > > + if (this_sa_flags & SA_SIGINFO) > > + { > > + context.uc_link = 0; > > + context.uc_flags = 0; > > + if (thissi.si_cyg) > > + memcpy (&context.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT)); > > + else > > + RtlCaptureContext ((CONTEXT *)&context.uc_mcontext); > > + /* FIXME: Really this should be the context which the signal interrupted? */ > > + > > + /* FIXME: If/when sigaltstack is implemented, this will need to do > > + something more complicated */ > > + context.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase; > > + context.uc_stack.ss_flags = 0; > > + if (!NtCurrentTeb ()->DeallocationStack) > > + context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; > > + else > > + context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; > > + > > + thiscontext = &context; > > + } > > > > sigset_t this_oldmask = set_process_mask_delta (); > > - thiscontext.uc_sigmask = this_oldmask; > > + context.uc_sigmask = this_oldmask; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > This call to set_process_mask_delta() should occur before constructing > the context, so that filling in uc_sigmask can be moved into the above > `'if' branch. > > On second thought, isn't this slightly wrong anyway? Shouldn't that be > > context.uc_sigmask = _my_tls.sigmask; > context.uc_mcontext.oldmask = this_oldmask; Oh, btw., what about cr2? Right now, with the above code, it contains a random value. It should at least be zero'ed out. Alternatively: context.uc_mcontext.cr2 = (thissi.si_signo == SIGSEGV || thissi.si_signo == SIGBUS) ? (uintptr_t) thissi.si_addr : 0; Thanks, Corinna -- Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat