How to make the PCC dump core
Donn Seeley
donn at utah-cs.UUCP
Sat Oct 6 18:47:25 AEST 1984
Almost no one rose to the bait when I issued a challenge to find the
shortest inputs that cause the Portable C Compiler to dump core. I
don't know whether to be happy that the compiler is so robust or
disappointed that I won't get more experience fixing PCC bugs...
If this is a dull afternoon, you may be interested in examining the
'programs' I had in mind. Here is the shortest string I could find
that could be compiled in the normal way to achieve a core dump with
the 4.2 BSD PCC on the VAX (note, no trailing newline):
*1e38*2
This 7-byte 'program' causes a floating exception when the compiler
attempts to evaluate the constant expression '1e38 * 2', which of
course is outside the range of the VAX's D- and F- float arithmetic.
This bug can be fixed by arranging to catch SIGFPE and complaining when
it occurs; I can provide code on request.
A much shorter 'program' can be used to get a core dump if you allow me
to sneak past the preprocessor and provide input directly to the
compiler. This exercise results in a short but suspenseful wait,
followed by a segmentation fault:
echo -n '#' | /lib/ccom
There is a missing end-of-file check in mip/scan.c... Again, code can
be supplied on request. Neither of these bugs is so earthshaking that
we can't live with them, but they were fun to find and fix.
One last trick -- a short program to cause the compiler to go into an
infinite loop generating code (gets the error 'expression causes
compiler loop'). The amusing results can best be appreciated by
running:
echo -n 'i=i*i' | /lib/ccom
Haven't tried fixing this one yet,
Donn Seeley University of Utah CS Dept donn at utah-cs.arpa
40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn
More information about the Comp.lang.c
mailing list