From owner-freebsd-hackers Sun Jun 6 12:18:48 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from alive.znep.com (sense-sea-MegaSub-1-222.oz.net [216.39.144.222]) by hub.freebsd.org (Postfix) with ESMTP id 03B32150F5 for ; Sun, 6 Jun 1999 12:18:46 -0700 (PDT) (envelope-from marcs@znep.com) Received: from localhost (marcs@localhost) by alive.znep.com (8.9.1/8.9.1) with ESMTP id MAA01459; Sun, 6 Jun 1999 12:25:04 -0700 (PDT) (envelope-from marcs@znep.com) Date: Sun, 6 Jun 1999 12:25:04 -0700 (PDT) From: Marc Slemko To: Marc Tardif Cc: freebsd-hackers@FreeBSD.ORG Subject: Re: a.out behavior In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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 > #include > > 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