PDA

View Full Version : getdomainname() fails in x86_64 applications




bdoyle
Nov 7, 2008, 06:02 PM
getdomainname() is failing with errno=14 (bad address) when the test application is built 64bits. The same code works fine when compiled in 32bits. Anybody know how to solve or work around this problem? Where do I search for or file a bug against macosx?

Thanks,
Blade.

Testcase:


% cat getdomainname.cxx
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/param.h>
#include <errno.h>

int main(void)
{
char domain[MAXHOSTNAMELEN+1];
int retval = getdomainname(domain, MAXHOSTNAMELEN);

if(retval != 0)
printf("Bad call returns %d with errno %d\n", retval, errno);
else
printf("Domain Name=%s\n", domain);

return 0;
}

% g++ -m64 -g -o getdomainname getdomainname.cxx
%
./getdomainname
Bad call returns -1 with errno 14


% g++ -g -o getdomainname getdomainname.cxx
% ./getdomainname
Domain Name=+mydomain.com



lee1210
Nov 7, 2008, 09:35 PM
Did you try casting the second argument to size_t explicitly?

-Lee

bdoyle
Nov 11, 2008, 02:44 PM
Thanks for the suggestion. I just tried it but no luck. ;( No help from Apple support either. :mad: