This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/2351] New: second SIGFPE not caught by signal hadler


I expect the program below to run succesfully to completion (and exit with a 0
status). On both AMD 64 and Intel EM64T (but not on x86, IA64) the program
abends during the second division, despite the signal handler.

$ /lib64/tls/libc.so.6 && cat ~/tmp/t.c && gcc ~/tmp/t.c && ./a.out 
GNU C Library stable release version 2.3.4, 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 3.4.4 20050721 (Red Hat 3.4.4-2).
Compiled on a Linux 2.4.20 system on 2005-08-19.
Available extensions:
        GNU libio by Per Bothner
        crypt add-on version 2.1 by Michael Glad and others
        Native POSIX Threads Library by Ulrich Drepper et al
        The C stubs add-on version 2.1.2.
        GNU Libidn by Simon Josefsson
        BIND-8.2.3-T5B
        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>.
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>

jmp_buf env;

volatile sig_atomic_t traps;

void handler (int signo)
{
    ++traps;
    longjmp (env, 1);
}

volatile int zero;
volatile int one;
volatile int result;

int main ()
{
    signal (SIGFPE, handler);

    ++one;

    if  (0 == setjmp (env)) {
        printf ("first division\n");
        result = one / zero;
    }
    else {
        signal (SIGFPE, handler);
        printf ("second division\n");
        if  (0 == setjmp (env)) {
            result = one / zero;
        }
    }

    printf ("%d traps\n", traps);
}
first division
second division
Floating point exception

-- 
           Summary: second SIGFPE not caught by signal hadler
           Product: glibc
           Version: 2.3.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: sebor at roguewave dot com
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: x86_64-redhat-linux
  GCC host triplet: x86_64-redhat-linux
GCC target triplet: x86_64-redhat-linux


http://sourceware.org/bugzilla/show_bug.cgi?id=2351

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]