Date: Sat, 9 Apr 2011 15:15:42 +0200 From: Sami Kerola <kerolasa@iki.fi> To: freebsd-questions@freebsd.org Cc: Roar Pettersen <rope1968@gmail.com> Subject: malloc: errno: 22: Invalid argument Message-ID: <BANLkTikEZHkQhLYz9-gEGfJnSoDWSAKFxA@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
Hello FreeBSD answers, I am a maintainer of a dhcp analysis software, which is before exit checking errno. I got report from FreeBSD user, Roar who is CC:d, that my software is reporting invalid argument at that section of the program. After sending debugging messages back and forth issue was pinpointed to following code sample. -- snip #include <err.h> #include <errno.h> #include <stdlib.h> int main(void) { int *i; warn("errno: %d", errno); i =3D malloc(sizeof(int)); warn("errno: %d", errno); free(i); return (errno); } -- snip which will give following output: # ./a.out a.out: errno: 0: Unknown error: 0 a.out: errno: 22: Invalid argument Characteristics of the system are; FreeBSD 8.2-STABLE # gcc -v Using built-in specs. Target: i386-undermydesk-freebsd Configured with: FreeBSD/i386 system compiler Thread model: posix gcc version 4.2.1 20070719 [FreeBSD] /lib/libc.so.7 There is no malloc.conf file on system. I don't understand why the invalid argument is set. I do not feel comfortable to write 'if the system is FreeBSD do not care malloc related errno 22' to my code. That simply sounds wrong. Does someone have explanation what might be going on and/or advice how I should deal this thing in the code? Or is the whole thing some how environment related? Unfortunately I don't have FreeBSD installation. So even if you would not be a malloc specialist you can say reply and tell that the sample is or is not setting invalid argument. That will be evidence that the problem happens either on none, some or all other systems as well. Thanks in advance for help. --=20 =A0=A0 Sami Kerola =A0=A0 http://www.iki.fi/kerolasa/
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?BANLkTikEZHkQhLYz9-gEGfJnSoDWSAKFxA>