summaryrefslogtreecommitdiff
path: root/lib/c-stack.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2011-06-20 14:59:13 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2011-06-20 15:14:58 -0700
commit3c4ad6125cf33faf3cc090b4232d35f3866b9799 (patch)
treeee2ab39310dbfab4e2a1f9ee9a97f5beeec9c4ca /lib/c-stack.c
parentd80aff0ae74993962a24f205a356ffae59eab5be (diff)
downloadgnulib-3c4ad6125cf33faf3cc090b4232d35f3866b9799.tar.gz
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.
Diffstat (limited to 'lib/c-stack.c')
-rw-r--r--lib/c-stack.c25
1 files changed, 3 insertions, 22 deletions
diff --git a/lib/c-stack.c b/lib/c-stack.c
index 7f0f488456..e48b97c3b7 100644
--- a/lib/c-stack.c
+++ b/lib/c-stack.c
@@ -223,22 +223,6 @@ c_stack_action (void (*action) (int))
#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 @@ segv_handler (int signo, siginfo_t *info,
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