Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!burl!ulysses!allegra!mit-eddie!think!harvard!seismo!brl-tgr!tgr!lcc.rich-wiz@locus.ucla.edu From: lcc.rich-wiz@locus.ucla.edu (Richard Mathews) Newsgroups: net.unix-wizards Subject: floating point overflows (and how to catch them), HELP! Message-ID: <1240@brl-tgr.ARPA> Date: Thu, 5-Sep-85 00:03:13 EDT Article-I.D.: brl-tgr.1240 Posted: Thu Sep 5 00:03:13 1985 Date-Received: Fri, 6-Sep-85 03:46:52 EDT Sender: news@brl-tgr.ARPA Lines: 30 > If I compile and run the following program, it will continue until > a floating point overflow occurs and will then go and proccess > the interrupt routine. However, it seems that the return from the > interrupt routine is returning to the start of the instruction > which caused the overflow in the first place. Therefore, the program > just goes into an infinite loop printing the overflow message. > What exactly is happening here or what am I doing wrong ? Any help > greatly appreciated. > By the way, this is on a VAX11/780 running 4.1BSD > Cheers, > Scott Pace, ...!philabs!micomvax!othervax!scott You are not doing anything wrong, DEC is! I am sure they would claim this to be a feature (it is documented in the architecture handbook), but it sure looks like a bug to me. Anyway, the problem is that floating overflow, floating underflow, and floating divide by zero do not increment the PC (in the jargon of DEC, they are "faults" not "traps"). UNIX could correct for this by incrementing it for you, but no version I have seen does this. The only solution is for your signal handler to increment its return address by the size of the instruction which caused the fault. YUCCH. I have a routine which does just this (for several versions of UNIX). It is simple to write, but I would be happy to send it to anyone who is interested. Richard M. Mathews Locus Computing Corporation lcc.richard@LOCUS.UCLA.EDU lcc.richard@UCLA-CS {ucivax,trwrb}!lcc!richard {ihnp4,randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!richard