delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/22/18:28:07

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 <cgf-use-the-mailinglist-please AT cygwin DOT com>
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: <loom DOT 20090722T211710-662 AT post DOT gmane DOT org>
MIME-Version: 1.0
In-Reply-To: <loom.20090722T211710-662@post.gmane.org>
User-Agent: Mutt/1.5.20 (2009-06-14)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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  <ebb9 AT byu DOT net>
>
>	* 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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019