X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-3.1 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_102,RCVD_IN_DNSWL_LOW,SARE_SUB_ENC_UTF8,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org To: cygwin AT cygwin DOT com From: Eric Blake Subject: libsigsegv progress: SIGSEGV and =?utf-8?b?c2lnaW5mb190LnNpX2FkZHI=?= Date: Wed, 22 Jul 2009 21:18:57 +0000 (UTC) Lines: 35 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit User-Agent: Loom/3.14 (http://gmane.org/) X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: 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 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 -- 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