www.delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/07/22/17:19:26

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 <ebb9 AT byu DOT net>
Subject: libsigsegv progress: SIGSEGV and =?utf-8?b?c2lnaW5mb190LnNpX2FkZHI=?=
Date: Wed, 22 Jul 2009 21:18:57 +0000 (UTC)
Lines: 35
Message-ID: <loom.20090722T211710-662@post.gmane.org>
Mime-Version: 1.0
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: <cygwin.cygwin.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

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




--
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