From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: libsigsegv? Date: Thu, 11 Sep 2014 19:04:49 +0300 Message-ID: <83ha0e87oe.fsf@gnu.org> References: <83r3zi8a9m.fsf@gnu.org> <5411C47F.1040801@yandex.ru> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1410451530 29038 80.91.229.3 (11 Sep 2014 16:05:30 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 11 Sep 2014 16:05:30 +0000 (UTC) Cc: emacs-devel@gnu.org To: Dmitry Antipov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Sep 11 18:05:23 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XS6rk-0004J9-JW for ged-emacs-devel@m.gmane.org; Thu, 11 Sep 2014 18:05:00 +0200 Original-Received: from localhost ([::1]:39652 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS6rj-0000lF-Uh for ged-emacs-devel@m.gmane.org; Thu, 11 Sep 2014 12:04:59 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49711) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS6rR-0000kJ-P2 for emacs-devel@gnu.org; Thu, 11 Sep 2014 12:04:47 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XS6rM-00053F-2Q for emacs-devel@gnu.org; Thu, 11 Sep 2014 12:04:41 -0400 Original-Received: from mtaout20.012.net.il ([80.179.55.166]:45569) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XS6rL-000537-QM for emacs-devel@gnu.org; Thu, 11 Sep 2014 12:04:35 -0400 Original-Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0NBQ00400V85I900@a-mtaout20.012.net.il> for emacs-devel@gnu.org; Thu, 11 Sep 2014 19:04:34 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NBQ0040LVBL4V80@a-mtaout20.012.net.il>; Thu, 11 Sep 2014 19:04:34 +0300 (IDT) In-reply-to: <5411C47F.1040801@yandex.ru> X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.166 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:174180 Archived-At: > Date: Thu, 11 Sep 2014 19:49:19 +0400 > From: Dmitry Antipov > CC: emacs-devel@gnu.org > > 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.