Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Jan 2009 10:38:18 +0100
From:      Christoph Mallon <christoph.mallon@gmx.de>
To:        Garrett Cooper <yanefbsd@gmail.com>
Cc:        "amd64@freebsd.org" <amd64@freebsd.org>, Hackers freeBSD <freebsd-hackers@freebsd.org>
Subject:   Re: Confused by segfault with legitimate call to strerror(3) on	amd64 / sysctl(3) setting `odd' errno's
Message-ID:  <4970558A.1010705@gmx.de>
In-Reply-To: <7d6fde3d0901160119u7ca9606dw55300cd279410ad2@mail.gmail.com>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
Garrett Cooper schrieb:
> On Fri, Jan 16, 2009 at 12:58 AM, Garrett Cooper <yanefbsd@gmail.com> wrote:
>> On Fri, Jan 16, 2009 at 12:57 AM, Christoph Mallon
>> <christoph.mallon@gmx.de> 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:
> 
> #include <errno.h>
> #include <stdio.h>
> #include <sys/stat.h>
> 
> 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));

You are still using the wrong errno.
Also err() itself prints the error string using strerror(). There might 
be some interference when the result of one call to strerror() (your 
call) is used after another call to strerror() (err() internally).

I doubt there is a bug in the library, otherwise we would see many 
bugreports of segfaults on AMD64.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4970558A.1010705>