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

2009-01-17 Thread Dag-Erling Smørgrav
Garrett Cooper yanef...@gmail.com writes: #include err.h #include errno.h #include stdio.h #include sys/types.h #include sys/sysctl.h You should always put your sys includes before your non-sys includes, and in any case, sys/types.h should always come first. printf(Errno:

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

2009-01-17 Thread Mikko Työläjärvi
Hi Garrett, On Fri, 16 Jan 2009, Garrett Cooper wrote: On Fri, Jan 16, 2009 at 12:58 AM, Garrett Cooper yanef...@gmail.com wrote: On Fri, Jan 16, 2009 at 12:57 AM, Christoph Mallon christoph.mal...@gmx.de wrote: Garrett Cooper schrieb: Good point. I modified the source to do that. Thanks,

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

2009-01-16 Thread Garrett Cooper
Hi amd64 and Hackers, Uh, I'm really confused why 1) this error (errno = ENOMEM) would occur when I have more than enough free memory (both on x86 and amd64) and 2) why strerror would segfault in the call to errx in the attached sourcefile on amd64 only. Not initializing len causes the second

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

2009-01-16 Thread Garrett Cooper
On Fri, Jan 16, 2009 at 12:41 AM, Garrett Cooper yanef...@gmail.com wrote: Hi amd64 and Hackers, Uh, I'm really confused why 1) this error (errno = ENOMEM) would occur when I have more than enough free memory (both on x86 and amd64) and 2) why strerror would segfault in the call to errx in

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

2009-01-16 Thread Christoph Mallon
Garrett Cooper schrieb: Hi amd64 and Hackers, Uh, I'm really confused why 1) this error (errno = ENOMEM) would occur when I have more than enough free memory (both on x86 and amd64) and 2) why strerror would segfault in the call to errx in the attached sourcefile on amd64 only. Not

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

2009-01-16 Thread Garrett Cooper
On Fri, Jan 16, 2009 at 12:47 AM, Jacques Fourie jacques.fou...@gmail.com wrote: You need to initialize len to the number of entries in the mib array. Try adding 'len = 4' before calling sysctlnametomib() and see if your issues go away. Ok, that solution works (I think). So, problem 2

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

2009-01-16 Thread Maxim Konovalov
On Fri, 16 Jan 2009, 00:44-0800, Garrett Cooper wrote: On Fri, Jan 16, 2009 at 12:41 AM, Garrett Cooper yanef...@gmail.com wrote: Hi amd64 and Hackers, Uh, I'm really confused why 1) this error (errno = ENOMEM) would occur when I have more than enough free memory (both on x86 and amd64)

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

2009-01-16 Thread Jacques Fourie
On Fri, Jan 16, 2009 at 10:47 AM, Jacques Fourie jacques.fou...@gmail.com wrote: On Fri, Jan 16, 2009 at 10:44 AM, Garrett Cooper yanef...@gmail.com wrote: On Fri, Jan 16, 2009 at 12:41 AM, Garrett Cooper yanef...@gmail.com wrote: Hi amd64 and Hackers, Uh, I'm really confused why 1) this

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

2009-01-16 Thread Garrett Cooper
On Fri, Jan 16, 2009 at 12:57 AM, Christoph Mallon christoph.mal...@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

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

2009-01-16 Thread Jacques Fourie
On Fri, Jan 16, 2009 at 10:44 AM, Garrett Cooper yanef...@gmail.com wrote: On Fri, Jan 16, 2009 at 12:41 AM, Garrett Cooper yanef...@gmail.com wrote: Hi amd64 and Hackers, Uh, I'm really confused why 1) this error (errno = ENOMEM) would occur when I have more than enough free memory (both

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

2009-01-16 Thread Garrett Cooper
On Fri, Jan 16, 2009 at 12:58 AM, Garrett Cooper yanef...@gmail.com wrote: On Fri, Jan 16, 2009 at 12:57 AM, Christoph Mallon christoph.mal...@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

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

2009-01-16 Thread Christoph Mallon
Garrett Cooper schrieb: On Fri, Jan 16, 2009 at 12:58 AM, Garrett Cooper yanef...@gmail.com wrote: On Fri, Jan 16, 2009 at 12:57 AM, Christoph Mallon christoph.mal...@gmx.de wrote: Garrett Cooper schrieb: Good point. I modified the source to do that. Thanks, -Garrett You should reply to all

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

2009-01-16 Thread Christian Kandeler
On Friday 16 January 2009 09:53, Christoph Mallon wrote: int main() { int mib[4]; size_t len; if (sysctlnametomib(kern.ipc.shmmax, mib, len) != 0) { printf(Errno: %d\n, errno); errx(errno, Error: %s, strerror(errno));

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

2009-01-16 Thread Christoph Mallon
Christian Kandeler schrieb: On Friday 16 January 2009 09:53, Christoph Mallon wrote: int main() { int mib[4]; size_t len; if (sysctlnametomib(kern.ipc.shmmax, mib, len) != 0) { printf(Errno: %d\n, errno); errx(errno, Error: %s,

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

2009-01-16 Thread Garrett Cooper
On Fri, Jan 16, 2009 at 2:21 AM, Christoph Mallon christoph.mal...@gmx.de wrote: Christian Kandeler schrieb: On Friday 16 January 2009 09:53, Christoph Mallon wrote: int main() { int mib[4]; size_t len; if (sysctlnametomib(kern.ipc.shmmax, mib, len) != 0) {

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

2009-01-16 Thread Garrett Cooper
On Fri, Jan 16, 2009 at 2:35 AM, Garrett Cooper yanef...@gmail.com wrote: On Fri, Jan 16, 2009 at 2:21 AM, Christoph Mallon christoph.mal...@gmx.de wrote: Christian Kandeler schrieb: On Friday 16 January 2009 09:53, Christoph Mallon wrote: int main() { int mib[4]; size_t

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

2009-01-16 Thread Christoph Mallon
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.

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

2009-01-16 Thread Christoph Mallon
Garrett Cooper schrieb: On Fri, Jan 16, 2009 at 2:21 AM, Christoph Mallon christoph.mal...@gmx.de wrote: Christian Kandeler schrieb: On Friday 16 January 2009 09:53, Christoph Mallon wrote: int main() { int mib[4]; size_t len; if (sysctlnametomib(kern.ipc.shmmax, mib,

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

2009-01-16 Thread Danny Braniss
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

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

2009-01-16 Thread Christoph Mallon
Danny Braniss schrieb: 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

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

2009-01-16 Thread Danny Braniss
On Fri, Jan 16, 2009 at 01:33:38PM +0200, Danny Braniss wrote: 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)

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

2009-01-16 Thread Stefan Farfeleder
On Fri, Jan 16, 2009 at 01:33:38PM +0200, Danny Braniss wrote: 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)

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

2009-01-16 Thread Thierry Herbelot
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) {

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

2009-01-16 Thread Garrett Cooper
On Fri, Jan 16, 2009 at 2:52 AM, Thierry Herbelot thierry.herbe...@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;

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

2009-01-16 Thread Nate Eldredge
On Fri, 16 Jan 2009, Garrett Cooper wrote: On Fri, Jan 16, 2009 at 2:52 AM, Thierry Herbelot thierry.herbe...@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()

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

2009-01-16 Thread Stefan Farfeleder
On Fri, Jan 16, 2009 at 10:33:15AM -0800, Nate Eldredge wrote: Pop quiz: which of the following statements is correct? #include stdlib.h #include unistd.h execl(/bin/sh, /bin/sh, 0); execl(/bin/sh, /bin/sh, NULL); None, as NULL is allowed to expand to 0. You have to write