Date: Sun, 6 Jun 1999 12:25:04 -0700 (PDT) From: Marc Slemko <marcs@znep.com> To: Marc Tardif <intmktg@CAM.ORG> Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: a.out behavior Message-ID: <Pine.BSF.4.05.9906061221210.24565-100000@alive.znep.com> In-Reply-To: <Pine.SOL.4.10.9906061507390.21415-100000@Ocean.CAM.ORG>
index | next in thread | previous in thread | raw e-mail
On Sun, 6 Jun 1999, Marc Tardif wrote:
> The following code should obviously segfault:
Nope. There is no requirement that code segfault. C does not make any
promises that accessing memory that you have not allocated will do
anything.
> #include <stdio.h>
> #include <syslog.h>
>
> char buffer[4028];
>
> void main() {
> int i;
> for (i=0; i<=4028; i++)
> buffer[i]='A';
> syslog(LOG_ERR, buffer);
> }
>
> Now here's the problem:
> When compiling with "gcc file.c", the program segfaults.
> When compiling with "gcc -o file file.c", the program doesn't segfault.
Try renaming a.out to file. You will probably find it is due to the
length of the filename, since ARGV[0] is used by syslog.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.05.9906061221210.24565-100000>
