[comp.mail.mush] mush aborts with segmentation violation on 286 xenix

schaefer@CSE.OGC.EDU (Barton E. Schaefer) (09/17/89)

On Sep 15,  1:49am, Barton A. Fisk wrote:
} Subject: running mush on 286 xenix
} 
} After successfully compiling and running mush for a couple
} of weeks, the program now terminates immediately upon loading
} with the Segmentation violation message.

On Sep 14,  9:39pm, Roger A. Cornelius wrote:
} Subject: mush aborts with segmentation violation
} 
} mush has recently started aborting (at startup) with a segmentation
} violation error.  I have been unable to find any reason why.  It has
} worked for several months without a problem.  If I invoke it with
} debugging on (-d option), it will source the systemwide mushrc, and then
} my personal mushrc, then abort with the error.  I haven't made any
} changes recently to the system (that I know of anyway) which would cause
} this.

On Sep 16,  1:20am, Bob Leffler wrote:
} Subject: Re: mush aborts with segmentation violation
} 
} Since it's happening on more than one system, it appears to have been
} triggered by date sensitive routine.  Any ideas as to where to start
} looking?

Most (all?) of the date-sensitive routines are in dates.c.

In cases such as this, it is always best to answer the "Core dump? [n]"
prompt with "y" and get at least a partial stack trace by using a
debugger on the core file, then send the trace to Dan (and possibly me).

Do any of you know at what date this first started breaking?  Here's the
code that is most plausibly the problem:

    static int mtbl[]={0,31,59,90,120,151,181,212,243,273,304,334};
    int days_ctr;
    days_ctr = ((Year * 365) + ((Year + 3) / 4) + mtbl[Month-1] + Day + 6);

If we assume a date of 9/x/89, then we have 

    89 * 365 + (92 / 4) + 243 + x + 6 = 32757 + x

A little quick math shows we overflow a signed 16-bit int when x = 12.
Any chance this all started happening on September 12th?

Change the declaration of days_ctr to "long" and (almost) all should be
well.  (Would "unsigned" be better?  It's been a while since I used C on
Xenix.)  If I remember my 286 oddities right, it may also be necessary to
do some typecasts in the following few lines of code (all in parse_date()
in dates.c) that do modulo arithmetic on days_ctr, in order to get the
correct results.

-- 
Bart Schaefer           "And if you believe that, you'll believe anything."
                                                            -- DangerMouse
CSNET / Internet                schaefer@cse.ogc.edu
UUCP                            ...{sequent,tektronix,verdix}!ogccse!schaefer

henry@GARP.MIT.EDU (Henry Mensch) (09/17/89)

> Do any of you know at what date this first started breaking?  

well, there *was* a full moon last night :)


-- 
# Henry Mensch    /   <henry@garp.mit.edu>   /   E40-379 MIT,  Cambridge, MA
# <hmensch@uk.ac.nsfnet-relay> / <henry@tts.lth.se> / <mensch@munnari.oz.au>