floating point overflows (and how to catch them), HELP!

Richard Mathews lcc.rich-wiz at locus.ucla.edu
Thu Sep 5 14:03:13 AEST 1985


> 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 at LOCUS.UCLA.EDU
					       lcc.richard at UCLA-CS
				{ucivax,trwrb}!lcc!richard
 {ihnp4,randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!richard



More information about the Comp.unix.wizards mailing list