Comment 3 for bug 696834

Revision history for this message
Paul Goyette (paul-whooppee) wrote : Re: [Qemu-devel] [Bug 696834] [NEW] FP exception reporting not working on NetBSD host

On Mon, 3 Jan 2011, Paul Goyette wrote:

> The following is a complete, standalone test program:
>
> #include <ieeefp.h>
> #include <setjmp.h>
> #include <signal.h>
> #include <stdio.h>
>
> volatile int flt_signal = 0;
>
> static sigjmp_buf sigfpe_flt_env;
> static void
> sigfpe_flt_action(int signo, siginfo_t *info, void *ptr)
> {
>
> flt_signal++;
> siglongjmp(sigfpe_flt_env, 1);
> }
> int main(int argc, void *argv[])
> {
> struct sigaction sa;
> double d;
>
> printf("Start\n");
> if (sigsetjmp(sigfpe_flt_env, 0) == 0) {
> sa.sa_flags = SA_SIGINFO;
> sa.sa_sigaction = sigfpe_flt_action;
> sigemptyset(&sa.sa_mask);
> sigaction(SIGFPE, &sa, NULL);
> fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
> d = 1.0 / strtod("0", NULL);
> }
> printf("FPE signal handler invoked %d times.\n");

And, of course, I still missed the extra agument:

                 printf("FPE signal handler invoked %d times.\n", flt_signal);

> }
>
> Executing the program gives the following results:
>
> # cc -o test test.c
> # ./test
> Start
> FPE signal handler invoked 0 times.
> #
>
> On "real" hardware,
>
> {225} cc -o test test.c
> {226} ./test
> Start
> FPE signal handler invoked 1 times.
> {227}
>
>
> -------------------------------------------------------------------------
> | Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
> | Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
> | Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
> | Kernel Developer | | pgoyette at netbsd.org |
> -------------------------------------------------------------------------
>
> --
> You received this bug notification because you are a direct subscriber
> of the bug.
> https://bugs.launchpad.net/bugs/696834
>
> Title:
> FP exception reporting not working on NetBSD host
>
> Status in QEMU:
> New
>
> Bug description:
> I recognize that NetBSD is not one of the officially supported host OS. However, qemu 0.13.0 is available in the NetBSD pkgsrc collection, and works quite well. Well, with one exception (pun intended): It seems that Floating Point exceptions don't get reported properly.
>
> The following code-snippet demonstrates the problem:
>
>
> volatile int flt_signal = 0;
>
> static sigjmp_buf sigfpe_flt_env;
> static void
> sigfpe_flt_action(int signo, siginfo_t *info, void *ptr)
> {
> flt_signal++;
> }
>
> void trigger(void)
> {
> struct sigaction sa;
> double d = strtod("0", NULL);
>
> if (sigsetjmp(sigfpe_flt_env, 0) == 0) {
> sa.sa_flags = SA_SIGINFO;
> sa.sa_sigaction = sigfpe_flt_action;
> sigemptyset(&sa.sa_mask);
> sigaction(SIGFPE, &sa, NULL);
> fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
> printf("%g\n", 1 / d);
> }
> printf("FPE signal handler invoked %d times.\n");
> }
>
> To unsubscribe from this bug, go to:
> https://bugs.launchpad.net/qemu/+bug/696834/+subscribe
>
> !DSPAM:4d21f0752341470756574!
>
>
>

-------------------------------------------------------------------------
| Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer | | pgoyette at netbsd.org |
-------------------------------------------------------------------------