4-Mar-87 18:29:46-MST,5297;000000000000 Mail-From: BEEBE created at 4-Mar-87 18:29:43 Date: Wed 4 Mar 87 18:29:43-MST From: "Nelson H.F. Beebe" Subject: DVI driver update #6 To: $90%dhdurz1.bitnet@WISCVM.WISC.EDU, AustinS%ucbcmsa.edu@UTAH-CS.ARPA, Berg-lists%gsb-why@SCORE.STANFORD.EDU, CEL@CITHEX.CALTECH.EDU, Celoni@SCORE.STANFORD.EDU, Crawford-J%ohio-state.arpa@UTAH-CS.ARPA, CRM8701%tamvenus.bitnet@WISCVM.WISC.EDU, Dan%buchmd.bu-cs.arpa@UTAH-CS.ARPA, David%ci-dandelion.uucp@EDDIE.MIT.EDU, Gaspard%hroeur5.bitnet@WISCVM.WISC.EDU, Goodall%admin.okanagan.bcc.cdn@RELAY.CS.NET, James%vaxe.coe.northeastern.edu@UTAH-CS.ARPA, JRP%nplpsg.uucp@UTAH-CS.ARPA, Karney%ppc.mfenet@NMFECC.ARPA, Lamy%ai.toronto.edu@RELAY.CS.NET, MPC91B%dgogwd01.bitnet@WISCVM.WISC.EDU, RJones%uwovax.bitnet@WISCVM.WISC.EDU, RS%gnome.cs.cmu.edu@UTAH-CS.ARPA, Simon%m_scrvx2%slb-test.csnet.csnet-relay@CSNET-RELAY.ARPA, Stone%ruthep.rutgers.edu@RUTGERS.RUTGERS.EDU, System%uvphys.bitnet@WISCVM.WISC.EDU, Thobe@EE.UCLA.EDU, X854%ddagsi3.bitnet@WISCVM.WISC.EDU, Zeffi%finabo.bitnet@WISCVM.WISC.EDU cc: beebe@UTAH-SCIENCE.ARPA X-US-Mail: "Center for Scientific Computation, South Physics, University of Utah, Salt Lake City, UT 84112" X-Telephone: (801) 581-5254 Message-ID: <12283822029.27.BEEBE@UTAH-SCIENCE.ARPA> A couple of years ago, I spent some time debugging the DVIxxx drivers under Eunice (Wollongong's 4.1 BSD Unix underneath VAX VMS), trying to determine why they core dumped after completing successfully. The problem was reported again from a 4.2 Eunice site, and last week from a 4.2 BSD Unix VAX site. It does not occur in 4.3BSD, or in HPUX, or any other non-Unix system in which the family has been implemented. Stepping with the debugger, I found that the program would run successfully right up to the call to exit() in abortrun.h, then die after it entered exit(). I hit the problem again today on a 4.2 BSD Unix system on an Integrated Solutions machine, and can now report a solution. The report last week from Los Angeles pointed the finger at fclose(), and indeed, if each call to fclose() makes sure not to make the call if the file pointer is null, the core dumps no longer happen. Two modules, abortrun.h and dviterm.h are affected, and a VAX VMS DIFF listing is appended to this note. This is definitely a bug in 4.1 and 4.2 Unix, not the DVI drivers, but a workaround is necessary. The man page (man 3s fclose) states These routines return EOF if stream is not associated with an output file, or if buffered data cannot be transferred to that file. There is no mention of a subsequent core dump! I hit a second problem on the Integrated Solutions system: the global variable errno is not defined in the file errno.h; it is under VAX VMS and TOPS-20. dvihead.h therefore needs a change too for these systems. It must be inside a conditional, because in the coming ANSI C standard, errno will be defined as a macro in stddef.h, which will not necessarily expand to an extern int. Why it is not defined in errno.h is a mystery, since errno is unlikely to be used without errno.h to get definitions of error symbols. diff abortrun.h ************ File SYS$LIBROOT:[PLOT79.TEX.DVI]ABORTRUN.H;5 21 if (font_files[k].font_id != (FILE*)NULL) 22 (void)fclose(font_files[k].font_id); 23 24 if (dvifp != (FILE*)NULL) 25 (void)fclose(dvifp); 26 if (plotfp != (FILE*)NULL) 27 (void)fclose(plotfp); 28 if (g_dolog && (g_logfp != (FILE *)NULL)) ****** File SYS$LIBROOT:[PLOT79.TEX.DVI]ABORTRUN.H;4 21 (void)fclose(font_files[k].font_id); 22 23 (void)fclose(dvifp); 24 (void)fclose(plotfp); 25 if (g_dolog && (g_logfp != (FILE *)NULL)) ************ Number of difference sections found: 1 Number of difference records found: 7 DIFFERENCES /IGNORE=()/MERGED=1- SYS$LIBROOT:[PLOT79.TEX.DVI]ABORTRUN.H;5- SYS$LIBROOT:[PLOT79.TEX.DVI]ABORTRUN.H;4 diff dvihead.h ************ File SYS$LIBROOT:[PLOT79.TEX.DVI]DVIHEAD.H;8 338 #if (BSD41 | BSD42) 339 extern int errno; /* not in all errno.h files, sigh... */ 340 #endif 341 ****** File SYS$LIBROOT:[PLOT79.TEX.DVI]DVIHEAD.H;7 338 ************ Number of difference sections found: 1 Number of difference records found: 3 DIFFERENCES /IGNORE=()/MERGED=1- SYS$LIBROOT:[PLOT79.TEX.DVI]DVIHEAD.H;8- SYS$LIBROOT:[PLOT79.TEX.DVI]DVIHEAD.H;7 diff dviterm.h ************ File SYS$LIBROOT:[PLOT79.TEX.DVI]DVITERM.H;10 30 if (dvifp != (FILE*)NULL) 31 (void)fclose(dvifp); 32 if (plotfp != (FILE*)NULL) 33 (void)fclose(plotfp); 34 ****** File SYS$LIBROOT:[PLOT79.TEX.DVI]DVITERM.H;9 30 (void)fclose(dvifp); 31 (void)fclose(plotfp); 32 ************ Number of difference sections found: 1 Number of difference records found: 4 DIFFERENCES /IGNORE=()/MERGED=1- SYS$LIBROOT:[PLOT79.TEX.DVI]DVITERM.H;10- SYS$LIBROOT:[PLOT79.TEX.DVI]DVITERM.H;9 -------