Possible Bug in BSD

ed at mtxinu.UUCP ed at mtxinu.UUCP
Thu Feb 26 18:53:20 AEST 1987


In article <4685 at brl-adm.ARPA> sefunix%sefe.decnet at nwc-143b.arpa (SEFE::SEFUNIX) writes:
>We have run into a little problem on both Ultrix-32m (DEC microvax)
>and MT. Xinu 4.3BSD on a DEC microvax. Can someone try this program
>on their system and see if they also get a segmentation violation
>on the fopen of argv[1]. 
>
>And if so, why?
>
>#include <stdio.h>
>
>struct abc
>{
>	short Red;
>	short Green;
>	short Blue;
>	short Alpha;
>};
>
>main (argc, argv)
>int argc; 
>char **argv;
>{
>	FILE *f1, *fopen();
>
>	struct abc point[151][451];
>
>	if (argc !=2)
>	{
>	   puts("\n Usage: InputFileName \n");
>	   exit(1);
>	}
>
>	if((f1 = fopen(argv[1], "r")) == NULL )
>	{
>	   printf("I can't open %s\n", argv[1]);
>	   exit(1);
>	}
>
>	fclose(f1);
>}

A little investigation with adb shows that it crashes while pushing an
argument to fopen() onto the stack.  Notice that there is a *large*
automatic array (point) declared - a total of 544808 bytes (plus
whatever else is on the stack).  The default limit for stack size is
512k.  Increasing the stack limit (with the csh(1) limit command or
with a system call from the program) will solve the problem.  Note,
too, that it crashes just as well pushing the argument to fputs() if it's
called with the wrong number of arguments.

-- 
Ed Gould                    mt Xinu, 2560 Ninth St., Berkeley, CA  94710  USA
{ucbvax,decvax}!mtxinu!ed   +1 415 644 0146

"A man of quality is not threatened by a woman of equality."



More information about the Comp.unix.wizards mailing list