[PATCH] Segfault while unwinding an invalid function pointer

Andrew Haley aph@redhat.com
Thu Jan 31 14:24:00 GMT 2008


Andi Kleen wrote:
> 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.

You could, but you shouldn't.  I agree with Jakub: we don't want to be
messing with signal handlers.  For example, an application is perfectly
entitled to enable/disable SIGSEGV handlers whenever it wants.

This seems to me like the cure is worse than the disease.

Andrew.



More information about the Gcc-patches mailing list