[comp.windows.x] Server bug in miarc.c

martin@CITI.UMICH.EDU (12/20/88)

I found this bug after compiling the server with gcc.  This bug generates
floating point domain errors to the function asin().  It seems to be quite
benign using cc on most machines.  On the VAX it generates floating
exceptions, on the sun, it sometimes causes count to be somewhere between huge
and big and spins the server in an ever-lasting for loop.

The following is a diff which will fix it.  This is a three character diff
(delete one < and add a 1.).  I included it with the PurduePlus-speedups, and
the MIT fix3 to the server is aimed at this file too.  

So, you must apply fix3 from expo before this one.  You should be able to do
it by hand.  Just do a search for "lazy" and thats where it is.  It should be
obvious to those who read this patch that it is a valid bugfix, because of the
domain constraints on asin.  

See if you can figure out what (count = (int) NaN;) is.  It is either big and
negative (benign) or big and positive (spins for dayz).

Be sure to save the original for this one, cuz I hear that the file will be
patched again by the MIT boyz.  Thats why they didn't include this fix in fix3.

Marty.

p.s.  I almost forgot the patch!

*** ./server/ddx/mi/miarc.c.orig        Mon Dec 19 22:59:13 1988
--- ./server/ddx/mi/miarc.c     Mon Dec 19 22:59:35 1988
***************
*** 711,717 ****
       * I'm just using cdt 'cause I'm lazy.
       */
      cdt = fmax(parc->width, parc->height)/2.0;
!     if(cdt <= 0)
        return 0;
      dt = asin( 1.0 / cdt ); /* minimum step necessary */
      count = et/dt;
--- 711,717 ----
       * I'm just using cdt 'cause I'm lazy.
       */
      cdt = fmax(parc->width, parc->height)/2.0;
!     if(cdt < 1.0)
        return 0;
      dt = asin( 1.0 / cdt ); /* minimum step necessary */
      count = et/dt;