From owner-freebsd-current Wed Aug 26 06:14:55 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id GAA26856 for freebsd-current-outgoing; Wed, 26 Aug 1998 06:14:55 -0700 (PDT) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from gilgamesch.bik-gmbh.de (gilgamesch.bik-gmbh.de [194.233.237.91]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id GAA26848 for ; Wed, 26 Aug 1998 06:14:52 -0700 (PDT) (envelope-from cracauer@gilgamesch.bik-gmbh.de) Received: (from cracauer@localhost) by gilgamesch.bik-gmbh.de (8.8.8/8.7.3) id PAA21842; Wed, 26 Aug 1998 15:13:52 +0200 (MET DST) Message-ID: <19980826151352.A21229@cons.org> Date: Wed, 26 Aug 1998 15:13:52 +0200 From: Martin Cracauer To: Stephen Hocking-Senior Programmer PGS Tensor Perth , current@FreeBSD.ORG Subject: Re: Floating Point Exceptions, signal handlers & subsequent ops References: <199808250753.PAA29567@ariadne.tensor.pgs.com> <19980825180559.A9890@cons.org> <19980826144302.C20511@cons.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.93.1i In-Reply-To: <19980826144302.C20511@cons.org>; from Martin Cracauer on Wed, Aug 26, 1998 at 02:43:02PM +0200 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In <19980826144302.C20511@cons.org>, Martin Cracauer wrote: > In <19980825180559.A9890@cons.org>, Martin Cracauer wrote: > > In <199808250753.PAA29567@ariadne.tensor.pgs.com>, Stephen Hocking-Senior Programmer PGS Tensor Perth wrote: > > > > > > I've noticed in one of my applications that the first FP operation after > > > return from a caught SIGFPE is invalid. I have a signal handler installed that > > > just prints out some basic info (like "SIGFPE caught"). The first FP op after > > > this (in my case, converting a long to a double) just gives garbage. Repeat > > > the same statement and it gives a sensible result. Has anyone else seen this > > > before I file a PR with code to reproduce the problem? > > > > I just did a short test and for me the next FP operation after a > > caught SIGFPE (division by zero) is still sane (without > > setjump/jumpjump). > > I'm afraid I was talking nonsense here :-( This test program shows the > problem. Now the question, why did my other test work well...? Arg, this code doesn't work because it is missing includes, please ignore it. Give me a break, I'll follow up with a useful example later. > #include > #include > #include > > void > handler(int s) > { > write(1, "sig\n", 4); > } > > int > main(void) > { > double f0; > double f2; > double f4; > double f8; > double res; > > /* Prevent optimization */ > f0 = atof("0.0"); > f2 = atof("2.0"); > f4 = atof("4.0"); > f8 = atof("8.0"); > > signal (SIGFPE, handler); > > res = f2 / f0; > > printf("After division by zero: %g\n", res); > > res = f4 + f8; > > if (res != 12.0) { > printf("Next operation didn't work: %g\n", res); > } > else { > printf("Next operation worked: %g\n", res); > } > > return 0; > } -- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Martin Cracauer http://www.cons.org/cracauer BSD User Group Hamburg, Germany http://www.bsdhh.org/ To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message