getaddrinfo confusion (wine 1.5.5)

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
Emanuel Rietveld

getaddrinfo confusion (wine 1.5.5)

Post by Emanuel Rietveld »

Question: How can it be that getaddrinfo when called by a game returns
an error, but when I call it in a small test program with the same
parameters, is succeeds?

Details:

I have a game (League of Legends) that gives an assertion failed before
starting a game, as per this bug:
http://bugs.winehq.org/show_bug.cgi?id=29609

I am using wine 1.5.5

Using "ollydbg" 110 from http://ollydbg.de I have tracked down the code
path leading to the failed assertion.

The game calls getaddrinfo, checks the return value, and if it is not
happy with it, eventually gives the assertion failed message.

Using the debugger, I figured out exactly what parameters is calls
getaddrinfo with:

pNodeName = "" (pointer to empty string)
pServiceName = "0" (pointer to string "0")
pHints = Pointer to addrinfo structure filled as follows:
ai_flags = 0x1 (AI_PASSIVE)
ai_family = 0x2 (AF_INET)
ai_socktype= 0x2 (SOCK_DGRAM)
ai_protocol = 0x11 (IPPROTO_UDP)
ai_addrlen = 0
ai_canonname = NULL
ai_addr = NULL
ai_next = NULL
ppResult = (pointer to memory allocated by game)

What happens is that wine passes these parameters down to the native
getaddrinfo on my platform (Linux, Fedora 17) as follows

getaddrinfo(hostname, "0", pUnixhints, ppResult)

Wine has some logic to turn a nodeName that is the empty string "", into
the hostname before passing it to the native call.

Wine transforms the windows hints into unix hints with some helper
functions, but they do not appear to change the contents at all for
these particular values. The relevant code is in dlls/ws2_32/socket.c

When the game, through wine, calls my native getaddrinfo like that, it
retuns -2 (E_NONAME) which is transformed by wine into WSAHOST_NOT_FOUND
(0x2AF9) which the game doesn't like and leads to the assertion failed.

When I, in a small test program, call my native getaddrinfo with exactly
the same parameters, it succeeds (returns 0).

How can this happen? Please, any ideas, to help me continue debugging
this frustrating problem.

Thank you for reading this far.
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Post by lahmbi5678 »

Hi,

I'm not sure, if this will be helpful, but years ago there was a bug in wine with empty or malformatted hostnames. What does your hostname look like, is it just an empty string or something like "localhost", "127.0.0.1"? Maybe setting it to another value might help.
Bruno Jesus

getaddrinfo confusion (wine 1.5.5)

Post by Bruno Jesus »

On Fri, Jun 1, 2012 at 6:28 AM, Emanuel Rietveld <[email protected]> wrote:
Wine has some logic to turn a nodeName that is the empty string "", into the
hostname before passing it to the native call.

Wine transforms the windows hints into unix hints with some helper
functions, but they do not appear to change the contents at all for these
particular values. The relevant code is in dlls/ws2_32/socket.c
That logic was implemented to mime the windows functionality. If
you're on OSX you could try the patches from:
http://bugs.winehq.org/show_bug.cgi?id=29756
Emanuel Rietveld

getaddrinfo confusion (wine 1.5.5)

Post by Emanuel Rietveld »

On 06/01/2012 01:45 PM, lahmbi5678 wrote:
Hi,

I'm not sure, if this will be helpful, but years ago there was a bug in wine with empty or malformatted hostnames. What does your hostname look like, is it just an empty string or something like "localhost", "127.0.0.1"? Maybe setting it to another value might help.
My hostname is "seo" and this is what gets passed down to native
getaddrinfo too (I recompiled with an extra TRACE call just to see).

When I call native getaddrinfo with ("seo", "0", phints, ppResult) from
a test program it succeeds (return value 0), but when native getaddrinfo
is called from wine's getaddrinfo in dlls/ws2_32/socket.c with the exact
same values, it fails with EAI_NONAME (return value -2).
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Post by lahmbi5678 »

Hi,

still I'm just guessing, but what does your hosts file look like, how would your hostname be resolved, if you tried to ping it? Maybe wine expects some domain name in hosts, so that "seo" would become e.g. "seo.yourdomain.com".
Emanuel Rietveld

getaddrinfo confusion (wine 1.5.5)

Post by Emanuel Rietveld »

On 06/01/2012 03:14 PM, lahmbi5678 wrote:
Hi,

still I'm just guessing, but what does your hosts file look like, how would your hostname be resolved, if you tried to ping it? Maybe wine expects some domain name in hosts, so that "seo" would become e.g. "seo.yourdomain.com".
I'm really glad that you're helping me guess, I'm guessing too! My
hostfile is correct and I can ping seo by short name. It is not a FQDN.

If I calling getaddrinfo with those same parameters in a test program,
it returns success.

The game calls WS2_32::getaddrinfo in wine with nodename = "" and
service is "0". Wine turns this into nodename = "seo" (my hostname) and
service is "0", leaving the addrinfo structure the same.

Then wine calls

result = getaddrinfo("seo", "0", pUnixhints, res);

which results in result = -2 (EAI_NONAME)

If I write a test program like this

// includes omitted
int main (int argc, int argv) {
struct addrinfo unixhints, *res;
// initialization of unixhints omitted, same as in wine

result = getaddrinfo("seo", "0", &unixhits, &res);
printf("%d", result);
return result;
}

results in result = 0 (success).

How can wine get a different result from my test program?
Emanuel Rietveld

getaddrinfo confusion (wine 1.5.5)

Post by Emanuel Rietveld »

On Fri, Jun 1, 2012 at 3:28 PM, Emanuel Rietveld <[email protected]> wrote:
On 06/01/2012 03:14 PM, lahmbi5678 wrote:
Hi,

still I'm just guessing, but what does your hosts file look like, how
would your hostname be resolved, if you tried to ping it? Maybe wine expects
some domain name in hosts, so that "seo" would become e.g.
"seo.yourdomain.com".
My sincerest apologies. I wrote my previous reply from work in the
fullest confidence that "seo" was in my hosts file, but it was not.
After adding it to my hosts file the game no longer gives a failed
assertion. It does not matter if I let it resolve to 127.0.0.1 or my
local external ip address - both work. Thank you!

Obviously my configuration was incorrect. Is there anything wine could
do, to help a user with such incorrect configuration? Why exactly does
it fail if my hostname is not in /etc/hosts ?
lahmbi5678
Level 7
Level 7
Posts: 823
Joined: Thu Aug 27, 2009 6:23 am

Post by lahmbi5678 »

Hi,

No need to excuse. I can't tell you, why it fails in wine and works in your linux program. Anyone else? I just remember that this or something very similar had been quite an issue.
Locked