bug-gnulib
[Top][All Lists]
Advanced

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

a test-sigaction failure


From: Bruno Haible
Subject: a test-sigaction failure
Date: Sun, 28 Sep 2008 05:05:40 +0200
User-agent: KMail/1.5.4

Hi Eric,

I'm seeing this in "make check" of gettext:

../../../gettext-tools/gnulib-tests/test-sigaction.c:79: assertion failed
FAIL: test-sigaction

This is on Linux/x86 with glibc-2.3.6.

$ ./test-sigaction
$ rm test-sigaction
$ make test-sigaction
$ gcc  -g   -o test-sigaction test-sigaction.o ../gllib/libgnu.a 
$ ./test-sigaction 
$ gcc  -g   -o test-sigaction test-sigaction.o ../gllib/libgnu.a -lpthread
$ ./test-sigaction 
test-sigaction.c:79: assertion failed
Abgebrochen
$ /lib/libc.so.6 
GNU C Library stable release version 2.3.6, by Roland McGrath et al.
Copyright (C) 2005 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
Compiled by GNU CC version 4.0.2.
Compiled on a Linux 2.6.0-test3 system on 2005-11-13.
Available extensions:
        GNU libio by Per Bothner
        crypt add-on version 2.1 by Michael Glad and others
        linuxthreads-0.10 by Xavier Leroy
        GNU Libidn by Simon Josefsson
        BIND-8.2.3-T5B
        libthread_db work sponsored by Alpha Processor Inc
        NIS(YP)/NIS+ NSS modules 0.19 by Thorsten Kukuk
Thread-local storage support included.
For bug reporting instructions, please see:
<http://www.gnu.org/software/libc/bugs.html>.

So, it is the fact of linking with -lpthread which makes the test fail.

The gdb and strace output tell me that the problem happens during the
second 'raise (SIGABRT)' (line 100): the assertion
    ASSERT (sa.sa_handler == SIG_DFL)
in line 79 fails. The strace output is this:

$ strace -e trace=signal test-sigaction
rt_sigaction(SIGRTMIN, {0x40036590, [], SA_RESTORER, 0x400ab5b8}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0x40036620, [RTMIN], SA_RESTORER, 0x400ab5b8}, NULL, 8) 
= 0
rt_sigaction(SIGRT_2, {0x40035fe0, [], SA_RESTORER, 0x400ab5b8}, NULL, 8) = 0
rt_sigprocmask(SIG_BLOCK, [RTMIN], NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [33], NULL, 8) = 0
rt_sigaction(SIGABRT, {0x4003b170, [], SA_RESTORER, 0x400ab5b8}, NULL, 8) = 0
kill(10069, SIGABRT)                    = 0
--- SIGABRT (Aborted) @ 0 (0) ---
rt_sigaction(SIGABRT, NULL, {0x4003b170, [], SA_RESTORER, 0x400ab5b8}, 8) = 0
sigreturn()                             = ? (mask now [RTMIN])
rt_sigaction(SIGABRT, {0x4003b170, [], SA_RESTORER|SA_NOMASK|SA_ONESHOT, 
0x400ab5b8}, {0x4003b170, [], SA_RESTORER, 0x400ab5b8}, 8) = 0
kill(10069, SIGABRT)                    = 0
--- SIGABRT (Aborted) @ 0 (0) ---
rt_sigaction(SIGABRT, NULL, {SIG_DFL}, 8) = 0           <========= HERE
test-sigaction.c:79: assertion failed
rt_sigaction(SIGABRT, {SIG_DFL}, {SIG_DFL}, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [ABRT], NULL, 8) = 0
kill(10069, SIGABRT)                    = 0
--- SIGABRT (Aborted) @ 0 (0) ---
+++ killed by SIGABRT +++

The marked sigaction call retrieves a handler that is SIG_DFL. The problem
is that the linuxthreads implementation of libpthread contains an override
of sigaction! It is this override which returns a different sa_handler value
to the program.

The same executable, run on a Linux/x86 glibc-2.4 system with NPTL, works fine.

I propose this workaround:


2008-09-27  Bruno Haible  <address@hidden>

        * tests/test-sigaction.c (handler, main): Disable the check whether
        SA_RESETHAND has reverted the installed handler to SIG_DFL. Needed on
        glibc systems with LinuxThreads.

--- tests/test-sigaction.c.orig 2008-09-28 05:03:38.000000000 +0200
+++ tests/test-sigaction.c      2008-09-28 05:00:34.000000000 +0200
@@ -76,7 +76,12 @@
       ASSERT (sa.sa_handler == handler);
       break;
     case 1:
+      /* This assertion fails on glibc-2.3.6 systems with LinuxThreads,
+        when this program is linked with -lpthread, due to the sigaction()
+        override in libpthread.so.  */
+#if !defined __GLIBC__
       ASSERT (sa.sa_handler == SIG_DFL);
+#endif
       break;
     default:
       ASSERT (0);
@@ -89,24 +94,31 @@
   struct sigaction sa;
   struct sigaction old_sa;
   sa.sa_handler = handler;
+
   sa.sa_flags = 0;
   ASSERT (sigemptyset (&sa.sa_mask) == 0);
   ASSERT (sigaction (SIGABRT, &sa, NULL) == 0);
   ASSERT (raise (SIGABRT) == 0);
+
   sa.sa_flags = SA_RESETHAND | SA_NODEFER;
   ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0);
   ASSERT ((old_sa.sa_flags & MASK_SA_FLAGS) == 0);
   ASSERT (old_sa.sa_handler == handler);
   ASSERT (raise (SIGABRT) == 0);
+
   sa.sa_handler = SIG_DFL;
   ASSERT (sigaction (SIGABRT, &sa, &old_sa) == 0);
   ASSERT ((old_sa.sa_flags & SA_SIGINFO) == 0);
+#if !defined __GLIBC__ /* see above */
   ASSERT (old_sa.sa_handler == SIG_DFL);
+#endif
+
   sa.sa_handler = SIG_IGN;
   ASSERT (sigaction (SIGABRT, &sa, NULL) == 0);
   ASSERT (raise (SIGABRT) == 0);
   ASSERT (sigaction (SIGABRT, NULL, &old_sa) == 0);
   ASSERT (old_sa.sa_handler == SIG_IGN);
   ASSERT (raise (SIGABRT) == 0);
+
   return 0;
 }





reply via email to

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