From debbugs-submit-bounces@debbugs.gnu.org Tue Jul 07 16:12:12 2015 Received: (at submit) by debbugs.gnu.org; 7 Jul 2015 20:12:12 +0000 Received: from localhost ([127.0.0.1]:43722 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCZDv-0002kt-S6 for submit@debbugs.gnu.org; Tue, 07 Jul 2015 16:12:12 -0400 Received: from eggs.gnu.org ([208.118.235.92]:37187) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCZDt-0002kh-Vp for submit@debbugs.gnu.org; Tue, 07 Jul 2015 16:12:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCZDn-0004YU-6X for submit@debbugs.gnu.org; Tue, 07 Jul 2015 16:12:04 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50 autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:37383) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCZDn-0004YQ-46 for submit@debbugs.gnu.org; Tue, 07 Jul 2015 16:12:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCZDl-0007vr-F3 for bug-gnu-emacs@gnu.org; Tue, 07 Jul 2015 16:12:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCZDg-0004WR-Dh for bug-gnu-emacs@gnu.org; Tue, 07 Jul 2015 16:12:01 -0400 Received: from limerock02.mail.cornell.edu ([128.84.13.242]:37729) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCZDg-0004WN-AE for bug-gnu-emacs@gnu.org; Tue, 07 Jul 2015 16:11:56 -0400 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite3.serverfarm.cornell.edu [10.16.197.8]) by limerock02.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id t67KBsoW011646 for ; Tue, 7 Jul 2015 16:11:55 -0400 Received: from [10.128.131.118] (dhcp-gs-886.eduroam.cornell.edu [10.128.131.118]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id t67KBs4K019351 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Tue, 7 Jul 2015 16:11:54 -0400 Message-ID: <559C3289.9090906@cornell.edu> Date: Tue, 07 Jul 2015 16:11:53 -0400 From: Ken Brown User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: 25.0.50; Questionable call to getrlimit in handle_sigsegv Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) There is a call to setrlimit in main() that tries to increase the stack size. As a result of this, the value of rlim.rlim_cur in handle_sigsegv() might exceed the actual stack size. See Corinna Vinschen's message at https://www.cygwin.com/ml/cygwin/2015-07/msg00092.html for a more detailed explanation. Corinna suggests using pthread_getattr_np instead of getrlimit to avoid this problem, as in the following patch: diff --git a/src/sysdep.c b/src/sysdep.c index 91036f0..c49e333 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -1625,6 +1625,8 @@ handle_arith_signal (int sig) #ifdef HAVE_STACK_OVERFLOW_HANDLING +#include + /* -1 if stack grows down as expected on most OS/ABI variants, 1 otherwise. */ static int stack_direction; @@ -1642,9 +1644,11 @@ handle_sigsegv (int sig, siginfo_t *siginfo, void *arg) too nested calls to mark_object. No way to survive. */ if (!gc_in_progress) { - struct rlimit rlim; + pthread_attr_t attr; + size_t stacksize; - if (!getrlimit (RLIMIT_STACK, &rlim)) + if (!pthread_getattr_np (pthread_self (), &attr) + && !pthread_attr_getstacksize (&attr, &stacksize)) { /* STACK_DANGER_ZONE has to be bigger than 16K on Cygwin, for reasons explained in @@ -1657,7 +1661,7 @@ handle_sigsegv (int sig, siginfo_t *siginfo, void *arg) char *beg, *end, *addr; beg = stack_bottom; - end = stack_bottom + stack_direction * rlim.rlim_cur; + end = stack_bottom + stack_direction * stacksize; if (beg > end) addr = beg, beg = end, end = addr; addr = (char *) siginfo->si_addr; Of course, the definition of HAVE_STACK_OVERFLOW_HANDLING would have to be changed to ensure that pthread_getattr_np exists. In GNU Emacs 25.0.50.17 (x86_64-unknown-cygwin, GTK+ Version 3.14.13) of 2015-07-07 on moufang Repository revision: 0bfc94047da4960af55196242728a7a55120867f Windowing system distributor `The Cygwin/X Project', version 11.0.11701000 Configured using: `configure 'CFLAGS=-g3 -O0'' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND DBUS GSETTINGS NOTIFY ACL GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Making completion list... Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message dired format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util help-fns help-mode easymenu cl-loaddefs pcase cl-lib mail-prsvr mail-utils time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese charscript case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind gfilenotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 08 09:34:13 2015 Received: (at 21004) by debbugs.gnu.org; 8 Jul 2015 13:34:14 +0000 Received: from localhost ([127.0.0.1]:44155 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCpUK-0004cz-UA for submit@debbugs.gnu.org; Wed, 08 Jul 2015 09:34:13 -0400 Received: from b2bfep14.mx.upcmail.net ([62.179.121.59]:36089) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCpUE-0004ca-8I for 21004@debbugs.gnu.org; Wed, 08 Jul 2015 09:34:07 -0400 Received: from edge11.upcmail.net ([192.168.13.81]) by b2bfep14.mx.upcmail.net (InterMail vM.8.01.05.11 201-2260-151-128-20120928) with ESMTP id <20150708133359.GXRY11791.b2bfep14-int.chello.at@edge11.upcmail.net> for <21004@debbugs.gnu.org>; Wed, 8 Jul 2015 15:33:59 +0200 Received: from iznogoud.viz ([91.119.108.4]) by edge11.upcmail.net with edge id ppZy1q01005jbv70BpZzWx; Wed, 08 Jul 2015 15:33:59 +0200 X-SourceIP: 91.119.108.4 Received: from wolfgang by iznogoud.viz with local (Exim 4.85 (FreeBSD)) (envelope-from ) id 1ZCpU6-0000Wc-LB; Wed, 08 Jul 2015 15:33:58 +0200 From: Wolfgang Jenkner To: Ken Brown Subject: Re: bug#21004: 25.0.50; Questionable call to getrlimit in handle_sigsegv References: <559C3289.9090906@cornell.edu> Date: Wed, 08 Jul 2015 15:33:58 +0200 In-Reply-To: <559C3289.9090906@cornell.edu> (Ken Brown's message of "Tue, 07 Jul 2015 16:11:53 -0400") Message-ID: <85d202g4e1.fsf@iznogoud.viz> User-Agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (berkeley-unix) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 21004 Cc: 21004@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) On Tue, Jul 07 2015, Ken Brown wrote: > Of course, the definition of HAVE_STACK_OVERFLOW_HANDLING would have to > be changed to ensure that pthread_getattr_np exists. Other systems may have this under a different name (e.g., FreeBSD has pthread_attr_get_np and needs to include pthread_np.h). By the way, Guile has already some code to deal with this. From debbugs-submit-bounces@debbugs.gnu.org Wed Jul 08 10:21:07 2015 Received: (at 21004) by debbugs.gnu.org; 8 Jul 2015 14:21:07 +0000 Received: from localhost ([127.0.0.1]:44366 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCqDi-0005ma-Sa for submit@debbugs.gnu.org; Wed, 08 Jul 2015 10:21:07 -0400 Received: from limerock03.mail.cornell.edu ([128.84.13.243]:59663) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZCqDg-0005lq-1s for 21004@debbugs.gnu.org; Wed, 08 Jul 2015 10:21:04 -0400 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite4.serverfarm.cornell.edu [10.16.197.9]) by limerock03.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id t68EKvsJ013209; Wed, 8 Jul 2015 10:20:57 -0400 Received: from [10.128.0.45] (dhcp-ccc-45.eduroam.cornell.edu [10.128.0.45]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id t68EKuGw004513 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Wed, 8 Jul 2015 10:20:56 -0400 Message-ID: <559D31C8.6050905@cornell.edu> Date: Wed, 08 Jul 2015 10:20:56 -0400 From: Ken Brown User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Wolfgang Jenkner Subject: Re: bug#21004: 25.0.50; Questionable call to getrlimit in handle_sigsegv References: <559C3289.9090906@cornell.edu> <85d202g4e1.fsf@iznogoud.viz> In-Reply-To: <85d202g4e1.fsf@iznogoud.viz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -3.0 (---) X-Debbugs-Envelope-To: 21004 Cc: Dmitry Antipov , 21004@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.0 (---) On 7/8/2015 9:33 AM, Wolfgang Jenkner wrote: > On Tue, Jul 07 2015, Ken Brown wrote: > >> Of course, the definition of HAVE_STACK_OVERFLOW_HANDLING would have to >> be changed to ensure that pthread_getattr_np exists. > > Other systems may have this under a different name (e.g., FreeBSD has > pthread_attr_get_np and needs to include pthread_np.h). By the way, > Guile has already some code to deal with this. So someone (Dmitry?) would have to do some work to make this more portable. It may or may not be worth the trouble; I'm not even sure yet that recovery from stack overflow actually works (see bug#20996). Ken From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 16 03:58:21 2015 Received: (at 21004) by debbugs.gnu.org; 16 Jul 2015 07:58:21 +0000 Received: from localhost ([127.0.0.1]:50597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFe3g-0008Mm-IE for submit@debbugs.gnu.org; Thu, 16 Jul 2015 03:58:21 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:36874) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFe3e-0008MW-G2 for 21004@debbugs.gnu.org; Thu, 16 Jul 2015 03:58:19 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 7B4C71608D3; Thu, 16 Jul 2015 00:58:12 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id L_iXZHWvoBhK; Thu, 16 Jul 2015 00:58:11 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 1C97F160999; Thu, 16 Jul 2015 00:58:11 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id TaniRxZ_D6sv; Thu, 16 Jul 2015 00:58:11 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id E5EC11608D3; Thu, 16 Jul 2015 00:58:10 -0700 (PDT) Message-ID: <55A76412.80000@cs.ucla.edu> Date: Thu, 16 Jul 2015 00:58:10 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Ken Brown Subject: Re: 25.0.50; Questionable call to getrlimit in handle_sigsegv Content-Type: multipart/mixed; boundary="------------020709020406070408030000" X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: 21004 Cc: Corinna Vinschen , Eli Zaretskii , Wolfgang Jenkner , Dmitry Antipov , 21004@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) This is a multi-part message in MIME format. --------------020709020406070408030000 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Ken, thanks for reporting the problem in . Please try the attached patch. Although it avoids getrlimit and it works for me on both GNU/Linux and Solaris, I can't easily test it on Cygwin. I'll CC: this to Eli as a heads-up, as he's interested in the MS-Windows case. --------------020709020406070408030000 Content-Type: text/x-diff; name="0001-Better-heuristic-for-C-stack-overflow.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Better-heuristic-for-C-stack-overflow.patch" >From 4cb3a1e2e3563a1dc0969bce3edd84918067d199 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 16 Jul 2015 00:48:40 -0700 Subject: [PATCH] Better heuristic for C stack overflow Improve the heuristic for distinguishing stack overflows from other SIGSEGV causes (Bug#21004). Corinna Vinschen explained that the getrlimit method wasn't portable to Cygwin; see: https://www.cygwin.com/ml/cygwin/2015-07/msg00092.html Corinna suggested pthread_getattr_np but this also has problems. Instead, replace the low-level system stuff with a simple heuristic based on known good stack addresses. * src/eval.c, src/lisp.h (near_C_stack_top): New function. * src/sysdep.c: Don't include . (stack_direction): Remove. All uses removed. (stack_overflow): New function. (handle_sigsegv): Use it instead of incorrect getrlimit heuristic. Make SEGV fatal in non-main threads. --- src/eval.c | 6 ++++ src/lisp.h | 1 + src/sysdep.c | 93 ++++++++++++++++++++++++++++++++++++------------------------ 3 files changed, 63 insertions(+), 37 deletions(-) diff --git a/src/eval.c b/src/eval.c index 4f7f42f..9bdcf4b 100644 --- a/src/eval.c +++ b/src/eval.c @@ -200,6 +200,12 @@ backtrace_next (union specbinding *pdl) return pdl; } +/* Return a pointer to somewhere near the top of the C stack. */ +void * +near_C_stack_top (void) +{ + return backtrace_args (backtrace_top ()); +} void init_eval_once (void) diff --git a/src/lisp.h b/src/lisp.h index c3289c9..341603f 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -4029,6 +4029,7 @@ extern _Noreturn void verror (const char *, va_list) ATTRIBUTE_FORMAT_PRINTF (1, 0); extern void un_autoload (Lisp_Object); extern Lisp_Object call_debugger (Lisp_Object arg); +extern void *near_C_stack_top (void); extern void init_eval_once (void); extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); diff --git a/src/sysdep.c b/src/sysdep.c index 91036f0..30a55f1 100644 --- a/src/sysdep.c +++ b/src/sysdep.c @@ -79,9 +79,6 @@ along with GNU Emacs. If not, see . */ #include "msdos.h" #endif -#ifdef HAVE_SYS_RESOURCE_H -#include -#endif #include #include #include @@ -1625,14 +1622,58 @@ handle_arith_signal (int sig) #ifdef HAVE_STACK_OVERFLOW_HANDLING -/* -1 if stack grows down as expected on most OS/ABI variants, 1 otherwise. */ - -static int stack_direction; - /* Alternate stack used by SIGSEGV handler below. */ static unsigned char sigsegv_stack[SIGSTKSZ]; + +/* Return true if SIGINFO indicates a stack overflow. */ + +static bool +stack_overflow (siginfo_t *siginfo) +{ + /* In theory, a more-accurate heuristic can be obtained by using + GNU/Linux pthread_getattr_np along with POSIX pthread_attr_getstack + and pthread_attr_getguardsize to find the location and size of the + guard area. In practice, though, these functions are so hard to + use reliably that they're not worth bothering with. E.g., see: + https://sourceware.org/bugzilla/show_bug.cgi?id=16291 + Other operating systems also have problems, e.g., Solaris's + stack_violation function is tailor-made for this problem, but it + doesn't work on Solaris 11.2 x86-64 with a 32-bit executable. + + GNU libsigsegv is overkill for Emacs; otherwise it might be a + candidate here. */ + + if (!siginfo) + return false; + + /* The faulting address. */ + char *addr = siginfo->si_addr; + if (!addr) + return false; + + /* The known top and bottom of the stack. The actual stack may + extend a bit beyond these boundaries. */ + char *bot = stack_bottom; + char *top = near_C_stack_top (); + + /* Log base 2 of the stack heuristic ratio. This ratio is the size + of the known stack divided by the size of the guard area past the + end of the stack top. The heuristic is that a bad address is + considered to be a stack overflow if it occurs within + stacksize>>LG_STACK_HEURISTIC bytes above the top of the known + stack. This heuristic is not exactly correct but it's good + enough in practice. */ + enum { LG_STACK_HEURISTIC = 8 }; + + if (bot < top) + return 0 <= addr - top && addr - top < (top - bot) >> LG_STACK_HEURISTIC; + else + return 0 <= top - addr && top - addr < (bot - top) >> LG_STACK_HEURISTIC; +} + + /* Attempt to recover from SIGSEGV caused by C stack overflow. */ static void @@ -1640,35 +1681,15 @@ handle_sigsegv (int sig, siginfo_t *siginfo, void *arg) { /* Hard GC error may lead to stack overflow caused by too nested calls to mark_object. No way to survive. */ - if (!gc_in_progress) - { - struct rlimit rlim; + bool fatal = gc_in_progress; - if (!getrlimit (RLIMIT_STACK, &rlim)) - { - /* STACK_DANGER_ZONE has to be bigger than 16K on Cygwin, for - reasons explained in - https://www.cygwin.com/ml/cygwin/2015-06/msg00381.html. */ -#ifdef CYGWIN - enum { STACK_DANGER_ZONE = 32 * 1024 }; -#else - enum { STACK_DANGER_ZONE = 16 * 1024 }; -#endif - char *beg, *end, *addr; - - beg = stack_bottom; - end = stack_bottom + stack_direction * rlim.rlim_cur; - if (beg > end) - addr = beg, beg = end, end = addr; - addr = (char *) siginfo->si_addr; - /* If we're somewhere on stack and too close to - one of its boundaries, most likely this is it. */ - if (beg < addr && addr < end - && (addr - beg < STACK_DANGER_ZONE - || end - addr < STACK_DANGER_ZONE)) - siglongjmp (return_to_command_loop, 1); - } - } +#ifdef FORWARD_SIGNAL_TO_MAIN_THREAD + if (!fatal && !pthread_equal (pthread_self (), main_thread)) + fatal = true; +#endif + + if (!fatal && stack_overflow (siginfo)) + siglongjmp (return_to_command_loop, 1); /* Otherwise we can't do anything with this. */ deliver_fatal_thread_signal (sig); @@ -1683,8 +1704,6 @@ init_sigsegv (void) struct sigaction sa; stack_t ss; - stack_direction = ((char *) &ss < stack_bottom) ? -1 : 1; - ss.ss_sp = sigsegv_stack; ss.ss_size = sizeof (sigsegv_stack); ss.ss_flags = 0; -- 2.1.0 --------------020709020406070408030000-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 16 04:30:56 2015 Received: (at control) by debbugs.gnu.org; 16 Jul 2015 08:30:57 +0000 Received: from localhost ([127.0.0.1]:50612 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFeZE-0000jZ-4l for submit@debbugs.gnu.org; Thu, 16 Jul 2015 04:30:56 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:37475) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFeZB-0000jI-1z for control@debbugs.gnu.org; Thu, 16 Jul 2015 04:30:53 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 2FFEE1608D3 for ; Thu, 16 Jul 2015 01:30:47 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Adapr9d8gxPx for ; Thu, 16 Jul 2015 01:30:46 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 8E985160999 for ; Thu, 16 Jul 2015 01:30:46 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id VpTOzb6-mFAB for ; Thu, 16 Jul 2015 01:30:46 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 757AB1608D3 for ; Thu, 16 Jul 2015 01:30:46 -0700 (PDT) Message-ID: <55A76BB6.1090508@cs.ucla.edu> Date: Thu, 16 Jul 2015 01:30:46 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: control@debbugs.gnu.org Subject: 21004 has a patch Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) tags 21004 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 16 08:16:06 2015 Received: (at 21004) by debbugs.gnu.org; 16 Jul 2015 12:16:06 +0000 Received: from localhost ([127.0.0.1]:50739 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFi57-0000ux-Fq for submit@debbugs.gnu.org; Thu, 16 Jul 2015 08:16:05 -0400 Received: from limerock04.mail.cornell.edu ([128.84.13.244]:57058) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFi55-0000uP-Vu for 21004@debbugs.gnu.org; Thu, 16 Jul 2015 08:16:04 -0400 X-CornellRouted: This message has been Routed already. Received: from authusersmtp.mail.cornell.edu (granite4.serverfarm.cornell.edu [10.16.197.9]) by limerock04.mail.cornell.edu (8.14.4/8.14.4_cu) with ESMTP id t6GCFrp3016712; Thu, 16 Jul 2015 08:15:53 -0400 Received: from [192.168.1.4] (cpe-67-249-176-138.twcny.res.rr.com [67.249.176.138]) (authenticated bits=0) by authusersmtp.mail.cornell.edu (8.14.4/8.12.10) with ESMTP id t6GCFpbJ015597 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT); Thu, 16 Jul 2015 08:15:52 -0400 Subject: Re: 25.0.50; Questionable call to getrlimit in handle_sigsegv To: Paul Eggert References: <55A76412.80000@cs.ucla.edu> From: Ken Brown Message-ID: <55A7A071.60404@cornell.edu> Date: Thu, 16 Jul 2015 08:15:45 -0400 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <55A76412.80000@cs.ucla.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -3.6 (---) X-Debbugs-Envelope-To: 21004 Cc: Corinna Vinschen , Eli Zaretskii , Wolfgang Jenkner , Dmitry Antipov , 21004@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.6 (---) On 7/16/2015 3:58 AM, Paul Eggert wrote: > Ken, thanks for reporting the problem in . Please > try the attached patch. Although it avoids getrlimit and it works for me on > both GNU/Linux and Solaris, I can't easily test it on Cygwin. I'll CC: this to > Eli as a heads-up, as he's interested in the MS-Windows case. It works on Cygwin. Thanks. Ken From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 16 10:34:04 2015 Received: (at 21004) by debbugs.gnu.org; 16 Jul 2015 14:34:04 +0000 Received: from localhost ([127.0.0.1]:51244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFkEd-0004A0-OT for submit@debbugs.gnu.org; Thu, 16 Jul 2015 10:34:04 -0400 Received: from mtaout23.012.net.il ([80.179.55.175]:59691) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFkEa-00049Q-RB for 21004@debbugs.gnu.org; Thu, 16 Jul 2015 10:34:02 -0400 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0NRL00M0040IAD00@a-mtaout23.012.net.il> for 21004@debbugs.gnu.org; Thu, 16 Jul 2015 17:33:54 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0NRL00M664GH5EB0@a-mtaout23.012.net.il>; Thu, 16 Jul 2015 17:33:54 +0300 (IDT) Date: Thu, 16 Jul 2015 17:34:03 +0300 From: Eli Zaretskii Subject: Re: 25.0.50; Questionable call to getrlimit in handle_sigsegv In-reply-to: <55A76412.80000@cs.ucla.edu> X-012-Sender: halo1@inter.net.il To: Paul Eggert Message-id: <83a8uw6ujo.fsf@gnu.org> References: <55A76412.80000@cs.ucla.edu> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 21004 Cc: corinna-cygwin@cygwin.com, wjenkner@inode.at, dmantipov@yandex.ru, 21004@debbugs.gnu.org, kbrown@cornell.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > Date: Thu, 16 Jul 2015 00:58:10 -0700 > From: Paul Eggert > CC: 21004@debbugs.gnu.org, Eli Zaretskii , > Wolfgang Jenkner , > Dmitry Antipov , > Corinna Vinschen > > Ken, thanks for reporting the problem in . Please > try the attached patch. Although it avoids getrlimit and it works for me on > both GNU/Linux and Solaris, I can't easily test it on Cygwin. I'll CC: this to > Eli as a heads-up, as he's interested in the MS-Windows case. Thanks. The native MS-Windows build doesn't (yet) support stack-overflow recovery, so the affected code is not compiled into that build. From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 16 10:38:34 2015 Received: (at 21004-done) by debbugs.gnu.org; 16 Jul 2015 14:38:34 +0000 Received: from localhost ([127.0.0.1]:51248 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFkIz-0004Fy-J8 for submit@debbugs.gnu.org; Thu, 16 Jul 2015 10:38:33 -0400 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:43423) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1ZFkIy-0004Fm-15 for 21004-done@debbugs.gnu.org; Thu, 16 Jul 2015 10:38:32 -0400 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 681BA1608D3; Thu, 16 Jul 2015 07:38:25 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id ZtgUXIyfw2xP; Thu, 16 Jul 2015 07:38:23 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id C09CA160999; Thu, 16 Jul 2015 07:38:23 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Wns-z7mAmIcV; Thu, 16 Jul 2015 07:38:23 -0700 (PDT) Received: from [192.168.1.9] (pool-100-32-155-148.lsanca.fios.verizon.net [100.32.155.148]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 9CB751608D3; Thu, 16 Jul 2015 07:38:23 -0700 (PDT) Message-ID: <55A7C1DA.3090006@cs.ucla.edu> Date: Thu, 16 Jul 2015 07:38:18 -0700 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Eli Zaretskii Subject: Re: 25.0.50; Questionable call to getrlimit in handle_sigsegv References: <55A76412.80000@cs.ucla.edu> <83a8uw6ujo.fsf@gnu.org> In-Reply-To: <83a8uw6ujo.fsf@gnu.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -1.3 (-) X-Debbugs-Envelope-To: 21004-done Cc: wjenkner@inode.at, dmantipov@yandex.ru, 21004-done@debbugs.gnu.org, kbrown@cornell.edu X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.3 (-) Thanks, Ken and Eli, for the quick responses. I've installed the patch as master commit a5522abbca2235771384949dfa87c8efc68831b2 and am closing the bug. From unknown Tue Jun 17 22:30:57 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 14 Aug 2015 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator