bug-m4
[Top][All Lists]
Advanced

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

Re: 'make test' error


From: Bruno Haible
Subject: Re: 'make test' error
Date: Sat, 6 Dec 2008 15:02:01 +0100
User-agent: KMail/1.9.9

Eric Blake wrote:
> [adding bug-gnulib, since this affects the gnulib module c-stack]
> 
> According to Bruce Dugan on 11/30/2008 9:40 PM:
> > I'm  not sure what system information you need.
> >
> >   System Version: Mac OS X 10.5.5 (9F33)
> >   Kernel Version: Darwin 9.5.0
> >   frei0r-plugins-1.1.22
> >
> > ./configure ran successfully, however 'make test' threw the following error:
> >
> >     FAIL: test-c-stack2.sh
> 
> Thanks for the report.  Was this with libsigsegv installed, and if so,
> which version?  I don't have access to a MacOS machine

I have access to a MacOS X 10.5 machine. What happens in this test is that the
test program installs a SIGSEGV handler but then dies from a SIGBUS:

$ ./test-c-stack 1
Bus error
$ dtruss ./test-c-stack 1
setrlimit(0x1003, 0xBFFFF7B0, 0x3)               = 0 0
sigaltstack(0xBFFFF770, 0x0, 0x3)                = 0 0
sigaction(0xB, 0xBFFFF720, 0x0)          = 0 0

I'm applying the attached fix, using the info from libsigsegv/src/signals*.h.
It causes the test to be skipped:

PASS: test-c-stack.sh
cannot tell stack overflow from crash; consider installing libsigsegv
SKIP: test-c-stack2.sh

2008-12-06  Bruno Haible  <address@hidden>

        Fix a c-stack test failure on MacOS X.
        * m4/c-stack.m4 (AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC): Require
        AC_CANONICAL_HOST. Define FAULT_YIELDS_SIGBUS. If set, install a signal
        handler for SIGBUS as well.
        * lib/c-stack.c (c_stack_action): If FAULT_YIELDS_SIGBUS is set,
        install a signal handler for SIGBUS as well.
        Reported by Bruce Dugan <address@hidden> via Eric Blake.

*** lib/c-stack.c.orig  2008-12-06 14:57:09.000000000 +0100
--- lib/c-stack.c       2008-12-06 14:45:45.000000000 +0100
***************
*** 321,326 ****
--- 321,330 ----
    act.sa_handler = die;
  # endif
  
+ # if FAULT_YIELDS_SIGBUS
+   if (sigaction (SIGBUS, &act, NULL) < 0)
+     return -1;
+ # endif
    return sigaction (SIGSEGV, &act, NULL);
  }
  
*** m4/c-stack.m4.orig  2008-12-06 14:57:09.000000000 +0100
--- m4/c-stack.m4       2008-12-06 14:54:41.000000000 +0100
***************
*** 7,20 ****
  
  # Written by Paul Eggert.
  
! # serial 7
  
  AC_DEFUN([AC_SYS_XSI_STACK_OVERFLOW_HEURISTIC],
    [# for STACK_DIRECTION
     AC_REQUIRE([AC_FUNC_ALLOCA])
     AC_CHECK_FUNCS_ONCE([setrlimit])
     AC_CHECK_HEADERS_ONCE([ucontext.h])
  
     AC_CACHE_CHECK([for working C stack overflow detection],
       [ac_cv_sys_stack_overflow_works],
       [AC_TRY_RUN(
--- 7,39 ----
  
  # Written by Paul Eggert.
  
! # serial 8
  
  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])
  
+    dnl List of signals that are sent when an invalid virtual memory address
+    dnl is accessed, or when the stack overflows.
+    dnl Either { SIGSEGV } or { SIGSEGV, SIGBUS }.
+    case "$host_os" in
+      sunos4* | freebsd* | dragonfly* | openbsd* | netbsd* | kfreebsd* | 
knetbsd*) # BSD systems
+        FAULT_YIELDS_SIGBUS=1 ;;
+      hpux*) # HP-UX
+        FAULT_YIELDS_SIGBUS=1 ;;
+      macos* | darwin*) # MacOS X
+        FAULT_YIELDS_SIGBUS=1 ;;
+      gnu*) # Hurd
+        FAULT_YIELDS_SIGBUS=1 ;;
+      *)
+        FAULT_YIELDS_SIGBUS=0 ;;
+    esac
+    AC_DEFINE_UNQUOTED([FAULT_YIELDS_SIGBUS], [$FAULT_YIELDS_SIGBUS],
+      [Define to 1 if an invalid memory address access may yield a SIGBUS.])
+ 
     AC_CACHE_CHECK([for working C stack overflow detection],
       [ac_cv_sys_stack_overflow_works],
       [AC_TRY_RUN(
***************
*** 62,67 ****
--- 81,90 ----
           sigemptyset (&act.sa_mask);
           act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND;
           act.sa_handler = segv_handler;
+          #if FAULT_YIELDS_SIGBUS
+          if (sigaction (SIGBUS, &act, 0) < 0)
+            return -1;
+          #endif
           return sigaction (SIGSEGV, &act, 0);
         }
         static volatile int *
***************
*** 244,249 ****
--- 267,276 ----
           sigemptyset (&act.sa_mask);
           act.sa_flags = SA_NODEFER | SA_ONSTACK | SA_RESETHAND | SA_SIGINFO;
           act.sa_sigaction = segv_handler;
+          #if FAULT_YIELDS_SIGBUS
+          if (sigaction (SIGBUS, &act, 0) < 0)
+            return -1;
+          #endif
           return sigaction (SIGSEGV, &act, 0);
         }
         static volatile int *




reply via email to

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