Confused by segfault with legitimate call to strerror(3) on amd64 / sysctl (3) setting `odd' errno's

Garrett Cooper yanefbsd at gmail.com
Fri Jan 16 10:06:55 PST 2009


On Fri, Jan 16, 2009 at 2:52 AM, Thierry Herbelot
<thierry.herbelot at free.fr> wrote:
> Le Friday 16 January 2009, Garrett Cooper a écrit :
>> On Fri, Jan 16, 2009 at 2:21 AM, Christoph Mallon
>>
>> #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);
>>                 printf("%s\n", strerror(o_errno));
>>         }
>>
>>         return 0;
>>
>> }
>>
> with this, it's better on an amd64/ RELENG_7 machine :
>
> % diff -ub badfile.c.ori badfile.c
> --- badfile.c.ori       2009-01-16 11:49:44.778991057 +0100
> +++ badfile.c   2009-01-16 11:49:03.470465677 +0100
> @@ -1,6 +1,7 @@
>  #include <errno.h>
>  #include <stdio.h>
>  #include <sys/stat.h>
> +#include <string.h>
>
>  int
>  main()
>
>        Cheers
>
>        TfH

That's hilarious -- why does it pass though without issue on x86 though?
-Garrett


More information about the freebsd-hackers mailing list