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

Thierry Herbelot thierry.herbelot at free.fr
Fri Jan 16 03:10:47 PST 2009


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


More information about the freebsd-hackers mailing list