Mercurial > hg > octave-jordi > gnulib-hg
changeset 15303:5fa23c9b72d6
c-stack: stop worrying about stack direction
* lib/c-stack.c (find_stack_direction): Remove.
(segv_handler): Don't worry about stack direction growth, as it's
too much of a pain to configure this correctly, given how compilers
are optimizing-away our stack-growth detection code. Instead, assume
that any access to just before or just after the stack is OK.
* m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC):
Don't require AC_FUNC_ALLOCA; no longer needed.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 20 Jun 2011 14:59:13 -0700 |
parents | 8f229ae087b4 |
children | 578f64214a48 |
files | ChangeLog lib/c-stack.c m4/c-stack.m4 |
diffstat | 3 files changed, 16 insertions(+), 25 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2011-06-20 Paul Eggert <eggert@cs.ucla.edu> + + c-stack: stop worrying about stack direction + * lib/c-stack.c (find_stack_direction): Remove. + (segv_handler): Don't worry about stack direction growth, as it's + too much of a pain to configure this correctly, given how compilers + are optimizing-away our stack-growth detection code. Instead, assume + that any access to just before or just after the stack is OK. + * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): + Don't require AC_FUNC_ALLOCA; no longer needed. + 2011-06-20 Eric Blake <eblake@redhat.com> test-stat: don't allocate PATH_MAX bytes
--- a/lib/c-stack.c +++ b/lib/c-stack.c @@ -223,22 +223,6 @@ #elif HAVE_SIGALTSTACK && HAVE_DECL_SIGALTSTACK && HAVE_STACK_OVERFLOW_HANDLING -/* Direction of the C runtime stack. This function is - async-signal-safe. */ - -# if STACK_DIRECTION -# define find_stack_direction(ptr) STACK_DIRECTION -# else -# if ! SIGINFO_WORKS || HAVE_XSI_STACK_OVERFLOW_HEURISTIC -static int -find_stack_direction (char const *addr) -{ - char dummy; - return ! addr ? find_stack_direction (&dummy) : addr < &dummy ? 1 : -1; -} -# endif -# endif - # if SIGINFO_WORKS /* Handle a segmentation violation and exit. This function is @@ -266,17 +250,14 @@ if (0 < info->si_code) { /* If the faulting address is within the stack, or within one - page of the stack end, assume that it is a stack - overflow. */ + page of the stack, assume that it is a stack overflow. */ ucontext_t const *user_context = context; char const *stack_base = user_context->uc_stack.ss_sp; size_t stack_size = user_context->uc_stack.ss_size; char const *faulting_address = info->si_addr; - size_t s = faulting_address - stack_base; size_t page_size = sysconf (_SC_PAGESIZE); - if (find_stack_direction (NULL) < 0) - s += page_size; - if (s < stack_size + page_size) + size_t s = faulting_address - stack_base + page_size; + if (s < stack_size + 2 * page_size) signo = 0; # if DEBUG
--- a/m4/c-stack.m4 +++ b/m4/c-stack.m4 @@ -7,11 +7,10 @@ # Written by Paul Eggert. -# serial 12 +# serial 13 AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC], - [# for STACK_DIRECTION - AC_REQUIRE([AC_FUNC_ALLOCA]) + [ AC_REQUIRE([AC_CANONICAL_HOST]) AC_CHECK_FUNCS_ONCE([setrlimit]) AC_CHECK_HEADERS_ONCE([ucontext.h])