New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_SocketType_resolve fails #580
Comments
Huh, weird. Does this only happen if you explicitly request getaddrinfo('1.2.3.4', 0, 0, SOCK_STREAM, 0, 0) ? |
(I'm trying to figure out whether we should just relax the test, or if we should do some fixups in our |
I tried disabling the interface that had a default route configured on (I thought it might be a hack introduced to make v6 operations smoother for some applications) but the result is the same. Must be noted that I can't (or don't know how to) disable ::1 |
Okay, that's good to know... Another question: what do you get for: getaddrinfo("facebook.com", 0, family=socket.AF_INET6, type=socket.SOCK_STREAM)
getaddrinfo("vorpus.org", 0, family=socket.AF_INET6, type=socket.SOCK_STREAM) ? (That's one site that resolves to both an ipv4 and an ipv6, and one that resolves to just an ipv4.) Looking at the test more closely, I guess it is actually testing a real thing – when you have a getaddrinfo(host, port, sock.family, sock.type, sock.proto, flags) where for This is a pretty edge case-y kind of thing – it looks like the stdlib's version of this code never passes |
On an IPv4-only network, I get IPv4-mapped addresses for both hostnames. I will try later with IPv6 internet. |
OK, I thought hard about adding a real workaround, but I don't think it's worth it given that:
So here's a patch to disable that test on buggy systems, and then we can close this: #589 If it does start causing actual problems for someone, we can re-open this. Working around it should be fairly straightforward: you can detect an IPv4-mapped address with |
Just as a further datapoint: when I have IPv6 internet both |
Interesting. Could it be that all our CI systems think they have IPv6 enabled, and the funny behavior only happens when MacOS thinks it has IPv4 only? Seems weird given how allergic most cloud providers are to IPv6, but who knows... |
I don't think that's the reason, because resolving dotted IPv4 address strings (like |
Oh, right. So much for that guess. I guess if we really want to know then the next step is to start digging through https://opensource.apple.com/tarballs/Libinfo/ – but I don't think I'm that curious :-). |
Apparently on Mac, on some setups,
getaddrinfo()
will always return IPv4 mapped addresses regardless of whether the AI_V4MAPPED is actually set. This causes failures in this assertiontrio/trio/tests/test_socket.py
Lines 420 to 422 in fd0d877
This is probably a system configuration issue and maybe there is not much we can do about it. But it's causing our tests to fail on some machines. I've seen this happen regularly on my work laptop for some time (macOS 10.13.5, Python 3.6 and 3.7) and a couple other sprinters at EuroPython had the same issue. Good news is that it doesn't affect our Mac CI.
One potential (maybe not ideal) solution is to verify whether the system has this quirk and in that case skip the test.
Details
Calling getaddrinfo() on an IPv4 address, with AF_INET6 and the AI_V4MAPPED flag returns an IPv4-mapped IPv6 address. This is documented and works in all platforms.
If I only want IPv6 addresses I won't set the AI_V4MAPPED and I won't get any result back. For example, this is what happens on Linux:
But if I try the same on my Mac I still get the IPv4-mapped results, even though I shouldn't!
The text was updated successfully, but these errors were encountered: