From owner-freebsd-amd64@FreeBSD.ORG Sat Jan 17 22:16:29 2009 Return-Path: Delivered-To: amd64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 152A21065677; Sat, 17 Jan 2009 22:16:29 +0000 (UTC) (envelope-from mbsd@pacbell.net) Received: from nlpi015.prodigy.net (nlpi015.sbcis.sbc.com [207.115.36.44]) by mx1.freebsd.org (Postfix) with ESMTP id BA1998FC08; Sat, 17 Jan 2009 22:16:28 +0000 (UTC) (envelope-from mbsd@pacbell.net) Received: from antec (adsl-99-22-93-85.dsl.pltn13.sbcglobal.net [99.22.93.85]) (authenticated bits=0) by nlpi015.prodigy.net (8.13.8 smtpauth/dk/map_regex/8.13.8) with ESMTP id n0HM5WRs009370; Sat, 17 Jan 2009 16:05:52 -0600 Date: Sat, 17 Jan 2009 14:05:33 -0800 (PST) From: =?ISO-8859-1?Q?Mikko_Ty=F6l=E4j=E4rvi?= To: Garrett Cooper In-Reply-To: <7d6fde3d0901160119u7ca9606dw55300cd279410ad2@mail.gmail.com> Message-ID: <20090117140506.A2568@antec.home> References: <7d6fde3d0901160041n55466290l55f737d274a40895@mail.gmail.com> <49704AEC.3080709@gmx.de> <7d6fde3d0901160056y7c395cb1m4675a3957b85f33d@mail.gmail.com> <49704C13.60505@gmx.de> <7d6fde3d0901160058x785b0af7r741fc779eb537d5@mail.gmail.com> <7d6fde3d0901160119u7ca9606dw55300cd279410ad2@mail.gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: "amd64@freebsd.org" , Hackers freeBSD , Christoph Mallon Subject: Re: Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl(3) setting `odd' errno's X-BeenThere: freebsd-amd64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the AMD64 platform List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Jan 2009 22:16:29 -0000 Hi Garrett, On Fri, 16 Jan 2009, Garrett Cooper wrote: > On Fri, Jan 16, 2009 at 12:58 AM, Garrett Cooper wrote: >> On Fri, Jan 16, 2009 at 12:57 AM, Christoph Mallon >> wrote: >>> Garrett Cooper schrieb: >>>> >>>> Good point. I modified the source to do that. >>>> Thanks, >>>> -Garrett >>> >>> You should reply to all so the discussion stays on the list. >> >> Yeah, that was a goofup on my part. Go-go Gmail web interface! >> -Garrett > > Hmmm... looks like the strerror issue it could be a serious bug: Add #include . Without it you don't get the strerror() prototype, so the return value defaults to an int. Thus the compiler will truncate the pointer value to junk. The crash happens when formatting the output. Compile with -Wall and pay attention to warnings (or use -Werror) to catch these things. $.02, /Mikko > > #include > #include > #include > > int > main() > { > > struct stat sb; > > int o_errno; > > if (stat("/some/file/that/doesn't/exist", &sb) != 0) { > o_errno = errno; > printf("Errno: %d\n", errno); > err(errno, "%s", strerror(o_errno)); > } > > return 0; > > } > > [gcooper@optimus ~]$ ./badfile > Errno: 2 > badfile: Segmentation fault: 11 (core dumped) > > I rebuilt my kernel and installed it, and I rebuilt world, but > haven't installed it yet though, so let me reboot the amd64 machine > and see what happens (may be a mismatched ABI issue)... > Cheers, > -Garrett > _______________________________________________ > freebsd-amd64@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-amd64 > To unsubscribe, send any mail to "freebsd-amd64-unsubscribe@freebsd.org" >