[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: libsigsegv?
From: |
Eli Zaretskii |
Subject: |
Re: libsigsegv? |
Date: |
Thu, 11 Sep 2014 19:04:49 +0300 |
> Date: Thu, 11 Sep 2014 19:49:19 +0400
> From: Dmitry Antipov <address@hidden>
> CC: address@hidden
>
> On 09/11/2014 07:08 PM, Eli Zaretskii wrote:
>
> > Apropos stack overflow protection: why not use libsigsegv if it is
> > available? It is capable of doing what we want (AFAICT), and supports
> > more platforms, including MS-Windows.
>
> 1. Stefan's mood gets worse after each new library dependency.
But what is your take on this?
Please note that my suggestion is to use the library only
_if_available_, and only for stack overflow detection.
> 2. Basically libsigsegv uses the following heuristics to distinguish between
> stack overflow and other kinds of SIGSEGVs:
> a) If the fault address is near the stack pointer, it's a stack overflow.
> b) If the fault address is near and beyond the bottom of the stack's
> virtual
> memory area, it's a stack overflow.
> c) If the stack pointer is near the bottom of the stack's virtual memory
> area,
> it's a stack overflow.
>
> Currently we have only b), and this is the only thing which can be
> implemented
> staying in POSIX interfaces and without architecture-dependent tricks.
But libsigsegv already did all those tricks, and it stays stable for
quites some time on many platforms (the long and impressive list is in
the library, I suggest to take a look). So why not use all that
knowledge and experience?
> a) may be implemented in a small forest of #ifdefs, and it
> doesn't worth using an extra library.
Are you going to implement it for the platforms we support? The
library is exceedingly small and static, btw.
> c) is the most controversial - for example, on GNU/Linux it works
> by opening and reading /proc/self/maps. Do you really want to open and
> read file
> on SIGSEGV? I do not.
/proc/self/maps is not a real file, AFAIK.
Besides, other projects do that (e.g., Gawk). I don't see why we
shouldn't.