From: Ken Brown <kbrown@cornell.edu>
To: 21004@debbugs.gnu.org
Subject: bug#21004: 25.0.50; Questionable call to getrlimit in handle_sigsegv
Date: Tue, 07 Jul 2015 16:11:53 -0400 [thread overview]
Message-ID: <559C3289.9090906@cornell.edu> (raw)
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 <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 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)
next reply other threads:[~2015-07-07 20:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-07 20:11 Ken Brown [this message]
2015-07-08 13:33 ` bug#21004: 25.0.50; Questionable call to getrlimit in handle_sigsegv Wolfgang Jenkner
2015-07-08 14:20 ` Ken Brown
2015-07-16 7:58 ` Paul Eggert
2015-07-16 12:15 ` Ken Brown
2015-07-16 14:34 ` Eli Zaretskii
2015-07-16 14:38 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=559C3289.9090906@cornell.edu \
--to=kbrown@cornell.edu \
--cc=21004@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.