This is the mail archive of the
cygwin
mailing list for the Cygwin project.
libsigsegv progress: SIGSEGV and siginfo_t.si_addr
- From: Eric Blake <ebb9 at byu dot net>
- To: cygwin at cygwin dot com
- Date: Wed, 22 Jul 2009 21:18:57 +0000 (UTC)
- Subject: libsigsegv progress: SIGSEGV and siginfo_t.si_addr
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@byu.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