Bug 157584 - Second SIGFPE is missed
Summary: Second SIGFPE is missed
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 3
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Roland McGrath
QA Contact: Brian Brock
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-05-12 20:51 UTC by djm
Modified: 2007-11-30 22:11 UTC (History)
2 users (show)

Fixed In Version:
Clone Of:
Environment:
Last Closed: 2005-05-18 04:42:24 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
C source code (457 bytes, text/plain)
2005-05-12 20:51 UTC, djm
no flags Details

Description djm 2005-05-12 20:51:32 UTC
Description of problem:
I'm trying to catch SIGFPE when generated by an integer divide by 0 exception.
The first is caught and handled by my handler sucessfully.  The second
is handled by the kernel and never passed to my handler.

Version-Release number of selected component (if applicable):
I've tried this on FC2, FC3, and FC4T3 (all X86_64).  It works fine on RH73.

How reproducible:
Always.

Steps to Reproduce:
1. g++ -o t t.c
2. ./t
  
Actual results:
SIGFPE caught 1 of 2
Floating exception

Expected results: (from RH73)
SIGFPE caught 1 of 2
SIGFPE caught 2 of 2

Additional info:
source code
---------------------- CUT HERE ----------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <float.h>
#include <setjmp.h>

typedef void (*fptr)(int);

jmp_buf env;

void Catcher(int arg1) {
    static int count=1;
    printf("SIGFPE caught %d of 2\n", count++);
    longjmp(env,1);
}

void run_test(int a, int b) {
    signal(SIGFPE, (fptr)Catcher);
    if (setjmp(env)==0) {
        int c = a/b;
    }
}

int main (int argc, char** argv) {
    run_test(1,0);
    run_test(2,0);
}

Comment 1 djm 2005-05-12 20:51:32 UTC
Created attachment 114313 [details]
C source code

Comment 2 Roland McGrath 2005-05-18 04:42:24 UTC
The program should use sigsetjmp and siglongjmp.
Using plain longjmp to leave a signal handler leaves signals blocked.


Note You need to log in before you can comment on or make changes to this bug.