Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 16 Jan 2009 13:33:38 +0200
From:      Danny Braniss <danny@cs.huji.ac.il>
To:        Christoph Mallon <christoph.mallon@gmx.de>
Cc:        Christian Kandeler <christian.kandeler@hob.de>, Garrett Cooper <yanefbsd@gmail.com>, 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:  <E1LNmxG-000PSq-DI@kabab.cs.huji.ac.il>
In-Reply-To: <497065ED.7050705@gmx.de> 
References:  <7d6fde3d0901160041n55466290l55f737d274a40895@mail.gmail.com>  <49704AEC.3080709@gmx.de> <200901161039.00232.christian.kandeler@hob.de>  <49705FA2.2020605@gmx.de> <7d6fde3d0901160235o6aa1f096q11c5096b70f3577@mail.gmail.com> <497065ED.7050705@gmx.de>

next in thread | previous in thread | raw e-mail | index | archive | help
> Garrett Cooper schrieb:
> >     Ok, I just installworld'ed, recompiled the program with the
> > following modifications, and I still get segfaults. And the question
> > of the night is: why amd64 on a VERY recent CURRENT?
> >     I'm going to try the same app on an amd64 freebsd VMware instance
> > with RELENG_7.
> >     Remember: just because a bunch of other people aren't reporting
> > issues with CURRENT/amd64 doesn't mean that it isn't environmental,
> > related to my hardware or compile options ;).
> > Cheers,
> > -Garrett
> > 
> > #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;
> > 
> > }
> > 
> > #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;
> > 
> > }
> > 
> > [gcooper@optimus ~]$ gcc -o badfile badfile.c
> > [gcooper@optimus ~]$ ./badfile
> > Errno: 2
> > Segmentation fault: 11 (core dumped)
> > [gcooper@optimus ~]$
> 
> Well, compile with -g, start in gdb, check what value is wrong, the 
> usual stuff. Probably the return value of strerror() is interesting.

some facts:
#include <stdio.h>
int
main()
{
     printf("%s\n", strerror(2));
     return 0;
}

	1- it works fine on i386
	2- it bombs on amd64
	3- with a local strerror.c (instead of the one in libc)
	   works fine
so, there is something realy wrong going on here!
(and it gows back to at least 7.0-stable)

danny





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?E1LNmxG-000PSq-DI>