From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Ken Brown Newsgroups: gmane.emacs.bugs Subject: bug#21004: 25.0.50; Questionable call to getrlimit in handle_sigsegv Date: Tue, 07 Jul 2015 16:11:53 -0400 Message-ID: <559C3289.9090906@cornell.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1436300006 12811 80.91.229.3 (7 Jul 2015 20:13:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 7 Jul 2015 20:13:26 +0000 (UTC) To: 21004@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Tue Jul 07 22:13:14 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ZCZEv-00056d-Ji for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Jul 2015 22:13:13 +0200 Original-Received: from localhost ([::1]:60314 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCZEu-0008Gm-G5 for geb-bug-gnu-emacs@m.gmane.org; Tue, 07 Jul 2015 16:13:12 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:50848) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCZEq-0008GU-Fe for bug-gnu-emacs@gnu.org; Tue, 07 Jul 2015 16:13:09 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCZEk-0004kg-Vs for bug-gnu-emacs@gnu.org; Tue, 07 Jul 2015 16:13:08 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:42276) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCZEk-0004kO-Sa for bug-gnu-emacs@gnu.org; Tue, 07 Jul 2015 16:13:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1ZCZEk-0002m5-EJ for bug-gnu-emacs@gnu.org; Tue, 07 Jul 2015 16:13:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ken Brown Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 07 Jul 2015 20:13:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 21004 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.143629993210600 (code B ref -1); Tue, 07 Jul 2015 20:13:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 7 Jul 2015 20:12:12 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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. Original-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 Original-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 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:104808 Archived-At: 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)