+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
#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
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
# 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])