[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#21004: closed (25.0.50; Questionable call to getrl

From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#21004: closed (25.0.50; Questionable call to getrlimit in handle_sigsegv)
Date: Thu, 16 Jul 2015 14:39:02 +0000

Your message dated Thu, 16 Jul 2015 07:38:18 -0700
with message-id <address@hidden>
and subject line Re: 25.0.50; Questionable call to getrlimit in handle_sigsegv
has caused the debbugs.gnu.org bug report #21004,
regarding 25.0.50; Questionable call to getrlimit in handle_sigsegv
to be marked as done.

(If you believe you have received this mail in error, please contact

21004: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=21004
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 25.0.50; Questionable call to getrlimit in handle_sigsegv Date: Tue, 07 Jul 2015 16:11:53 -0400 User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
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


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)


+#include <pthread.h>
/* -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 (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:
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.

(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)

--- End Message ---
--- Begin Message --- Subject: Re: 25.0.50; Questionable call to getrlimit in handle_sigsegv Date: Thu, 16 Jul 2015 07:38:18 -0700 User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 Thanks, Ken and Eli, for the quick responses. I've installed the patch as master commit a5522abbca2235771384949dfa87c8efc68831b2 and am closing the bug.

--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]