Bug 157584

Summary: Second SIGFPE is missed
Product: [Fedora] Fedora Reporter: djm
Component: kernelAssignee: Roland McGrath <roland>
Status: CLOSED NOTABUG QA Contact: Brian Brock <bbrock>
Severity: medium Docs Contact:
Priority: medium    
Version: 3CC: davej, wtogami
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2005-05-18 04:42:24 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
C source code none

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.