4bsd-f77@utah-cs.UUCP (4.2 BSD f77 bug reports) (08/03/84)
From: Donn Seeley <donn@utah-cs.arpa> Subject: F77 dumps core on programs with certain kinds of ENTRY statements Index: usr.bin/f77/src/f77pass1/proc.c 4.2BSD Description: If a function has more than one entry point, and the first entry is of type COMPLEX or CHARACTER and some later entry point is of a different (arithmetic) type, f77 will fail to compile it. This bug was found by Raleigh Romine at the Center for Seismic Studies. Repeat-By: Clip out the following program and attempt to compile it: ---------------------------------------------------------------- complex function cxmpl() double precision dxmpl cxmpl = (0.0, 0.0) return entry dxmpl() dxmpl = 0.0 return end ---------------------------------------------------------------- The compiler will print something like 'Termination code 139' and there will be a big pile of core on your carpet. Fix: (No, you can't train it with newspapers...) The entry point processing code wants to allocate a temporary to store a data structure for the return values of all entry points with simple return values (i.e. not COMPLEX or CHARACTER type entries, which are handled with hidden function arguments). The problem is that it only does this if the FIRST entry point has a simple return value, not if ANY entry point has a simple return value. As a result the compiler doubly dereferences a null pointer, with a predictable outcome. There is a one-line change to doentry() in proc.c which fixes this: ---------------------------------------------------------------- *** /tmp/,RCSt1004731 Fri Jul 20 17:25:48 1984 --- /tmp/,RCSt2004731 Fri Jul 20 17:25:52 1984 *************** *** 438,444 } else if(type != TYSUBR) { ! if(nentry == 1) retslot = autovar(1, TYDREAL, PNULL); np->vstg = STGAUTO; np->voffset = retslot->memoffset->constblock.const.ci; --- 443,449 ----- } else if(type != TYSUBR) { ! if(retslot == NULL) retslot = autovar(1, TYDREAL, PNULL); np->vstg = STGAUTO; np->voffset = retslot->memoffset->constblock.const.ci; ---------------------------------------------------------------- How much/ is that compiler/ in the window? Donn Seeley University of Utah CS Dept donn@utah-cs.arpa 40 46' 6"N 111 50' 34"W (801) 581-5668 decvax!utah-cs!donn