[Bug 44676] Re: cannot allocate memory

flashydave dave at opensourcesolutions.co.uk
Wed Oct 1 21:42:11 UTC 2008

Ive not tried building on 8.10 (I might try it as I have a server
already built with Intrepid on)

Having said that the problem is caused at run time by a failure in get_hostnamestr() in inetutils.c which is meant to return a string.
There is a section in the definition starting #ifdef HAVE_IP6 which is missing from the compiled code because HAVE_IP6 is not defined properly on some platforms (see next para).
The net result an else clause gets executed resulting in the function returning  NULL.
This is used in server.c main() around line 4060 where there is function call :
  EM__(remotehost = get_connected_peername(commrfd))
which indirectly calls get_hostnamestr()
The EM__ macro mis-interprets the remotehost=NULL response and misleadingly reports an Out of Memory error. 
This should be improved - the macro shouldnt be used in this context.

Having said that the issue is actually triggered by  the HAVE_IP6. 
On my 64 bit Hardy system strace shows that the getpeername() library call is as follows:
getpeername(sa_family=AF_INET6, sin6_port=htons(55263), inet_pton(AF_INET6, "::ffff:", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0
As you can see it is using AF_INET6 family. This is what the missing piece of code mentioned above is meant to deal with.

Why is HAVE_IP6 not defined?
Because when built "configure" fails to detect ipv6 running. It fails with

configure:5450: cc -o conftest -g -O2 -g -Wall -O2   -Wl,-Bsymbolic-functions conftest.c  -lpthread 1>&5
configure: In function 'sigh':
configure:5441: warning: implicit declaration of function 'exit'
configure:5441: warning: incompatible implicit declaration of built-in function 'exit'
configure: In function 'main':
configure:5446: warning: implicit declaration of function 'getmntent'
configure:5532: checking for IPv6 implementation
configure:5546: cc -o conftest -g -O2 -g -Wall -O2   -Wl,-Bsymbolic-functions conftest.c  -lpthread 1>&5
In file included from /usr/include/netinet/in.h:24,
                 from configure:5539:
/usr/include/stdint.h:49: error: duplicate 'unsigned'
/usr/include/stdint.h:49: error: two or more data types in declaration specifiers
/usr/include/stdint.h:50: error: duplicate 'unsigned'
/usr/include/stdint.h:50: error: duplicate 'short'
/usr/include/stdint.h:52: error: duplicate 'unsigned'
configure: In function 'main':
configure:5542: warning: unused variable 'sock6'
configure:5542: warning: unused variable 'in6'
configure: failed program was:
#line 5537 "configure"
#include "confdefs.h"

#include <netinet/in.h>

int main() {
 struct in6_addr in6; struct sockaddr_in6 sock6;
; return 0; }

This has nothing to do with the ipv6 test being performed but due (my guess) to a compiler issue (It is using gcc 4.2.3)
Strangely compiling the same code outside configure on the command line DOESNT generate the same error.

I'm not sure how we fix it properly. Maybe someone else knows the answer
to that....

As a quick interim fix you could switch of ipv6 on your PC (a little
severe). That would avoid the system going through the bad piece of

I've temporarily fixed it by tweaking configure always to set ac_cv_struct_in6_addr=yes
whether or not the test fails and rebuilding the binary. This is a horrid workaround hack for my system only where I know ipv6 is running.

Hope that helps!

cannot allocate memory
You received this bug notification because you are a member of MOTU,
which is a bug assignee.

More information about the universe-bugs mailing list