X-Recipient: archive-cygwin AT delorie DOT com X-Spam-Check-By: sourceware.org Date: Wed, 22 Jul 2009 18:26:47 -0400 From: Christopher Faylor To: cygwin AT cygwin DOT com Subject: Re: libsigsegv progress: SIGSEGV and siginfo_t.si_addr Message-ID: <20090722222647.GC14502@ednor.casa.cgf.cx> Reply-To: cygwin AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.20 (2009-06-14) Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com On Wed, Jul 22, 2009 at 09:18:57PM +0000, Eric Blake wrote: >POSIX requires that for SIGSEGV and SIGBUS, the si_addr member of siginfo_t be >set to the memory address where access failed, and not the address of the >instruction attempting to access that address (for SIGILL and SIGFPE, the >si_addr field is correct, and for all other signals, the si_addr is unspecified >by POSIX so it might as well be the faulting instruction). > >Fixing si_addr to contain the correct information will make it possible to >patch libsigsegv to avoid installing an SEH handler for all but stack >overflow. (Without this patch, I think I can still patch libsigsegv to honor >SIGSEGV, but it will be a much bigger hack of still installing a libsigsegv SEH >handler that sniffs the faulting address, then in the SIGSEGV handler refers to >the address that was sniffed). > >2009-07-22 Eric Blake > > * exceptions.cc (handle_exceptions): Set si_addr according to > POSIX for SIGSEGV. > >diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc >index 7663285..df02489 100644 >--- a/winsup/cygwin/exceptions.cc >+++ b/winsup/cygwin/exceptions.cc >@@ -686,7 +686,8 @@ _cygtls::handle_exceptions (EXCEPTION_RECORD *e, >exception_list *frame, CONTEXT > me.signal_exit (0x80 | si.si_signo); // Flag signal + core dump > } > >- si.si_addr = (void *) in->Eip; >+ si.si_addr = (si.si_signo == SIGSEGV || si.si_signo == SIGBUS >+ ? (void *) e->ExceptionInformation[1] : (void *) in->Eip); > si.si_errno = si.si_pid = si.si_uid = 0; > me.incyg++; > sig_send (NULL, si, &me); // Signal myself Looks ok. Please check in. Thanks for the patch. cgf -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple