This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Segfault while unwinding an invalid function pointer
- From: Andi Kleen <andi at firstfloor dot org>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Andi Kleen <andi at firstfloor dot org>, Pete Eberlein <eberlein at linux dot vnet dot ibm dot com>, gcc-patches at gcc dot gnu dot org
- Date: Thu, 31 Jan 2008 12:34:26 +0100
- Subject: Re: [PATCH] Segfault while unwinding an invalid function pointer
- References: <47A0F9FA.9000903@linux.vnet.ibm.com.suse.lists.egcs-patches> <p73r6fy46fh.fsf@bingen.suse.de> <20080131105359.GS30691@devserv.devel.redhat.com>
On Thu, Jan 31, 2008 at 05:53:59AM -0500, Jakub Jelinek wrote:
> On Thu, Jan 31, 2008 at 11:48:18AM +0100, Andi Kleen wrote:
> > mincore is racy because the page could be just munmaped by a different
> > thread in the window between the call and the access. The only way to make it
> > safe would be to use mlock, but that might require root.
> >
> > Better would be to install a signal handler and handle the exception.
> > Might be tricky to coordinate this with other signal handlers though.
>
> That's not something the unwinder can/should do. Signal handlers are
> process-wide, a library shouldn't mess up with application's signal handlers
> and some other thread can change the signal handler in the mean time anyway.
If you have glibc support you could certainly hook into sigaction() and
friends and e.g. make all signal handlers go through a trampoline that
checks for the unwind case.
In fact you could do it even without glibc support by overriding sigaction.
-Andi