-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 to_socket_addr_str_bad is broken on macOS too #53957
Comments
I switched ISPs recently and I am now observing this problem on my local MacOS development box. Needless to say, it is annoying. I want to try to reconstruct the history of how we even got here.
|
Perhaps most importantly, the conversion in question does not return Here is the code I was using to observe the behavior: use std::net::{SocketAddr, ToSocketAddrs};
fn main() {
// Convert input to `Debug` fmt'able form.
fn tsa<A: ToSocketAddrs>(a: A) -> Result<Vec<SocketAddr>, String> {
match a.to_socket_addrs() {
Ok(a) => Ok(a.collect()),
Err(e) => Err(e.to_string()),
}
}
println!("{:?}", tsa("1200::AB00:1234::2552:7777:1313:34300"));
} |
The next question I have is: Why isn't this invalid input causing an error prior to the attempt to do a DNS resolve? Interestingly, the original test case filed in issue #23076 does seem to behave as expected on my MacOS machine: an attempt to evaluate So even though the DNS resolve call "succeeds" by returning the IP address of the DNS server, something further along in the system still ensures that the attempt to bind a I take this to mean that we may have another choice to make with respect to the failing test here: Perhaps we should replace the existing test that has flaky behavior with a new test that better matches the original problem. |
Some context: my provider had a "feature": it resolved any DNS name to its own name, so opening a website with misspelt name opens a page with lots of ads. See the
A user cannot bind a socket to a non-local address if I got your comment correctly, that's expected behavior. |
Yes, thank you @stepancheg for that clarifying note. I think the choices in front of us are roughly as you stated in the description: either:
What we should not do is continue to let this test flummox developers in a manner dependent on what DNS resolution service they happen to be using. |
…-23076, r=LukasKalbertodt For issue 53957: revise unit test to focus on underlying bug of 23076. Fix rust-lang#53957 by revising unit test to focus on underlying bug of rust-lang#23076. Namely, this version focuses on the end-to-end behavior that the attempt to create the UDP binding will fail, regardless of the semantics of how particular DNS servers handle junk inputs. (I spent some time trying to create a second more-focused test that would sidestep the DNS resolution, but this is not possible without more invasive changes to the internal infrastructure of `ToSocketAddrs` and what not. It is not worth it.)
This is the test from rust source repository.
It says, the test fails on openbsd and bitrig, but it also fails on macOS.
I guess the reason is this:
194.168.4.100
is an IP address of DNS of my ISP.So for some reason, macOS decides to resolve string
1200::AB00:1234::2552:7777:1313
using DNS, and on certain ISP this resolution success.I think rust should either:
The text was updated successfully, but these errors were encountered: