Add getaddrinfo and freeaddrinfo shims#4984
Add getaddrinfo and freeaddrinfo shims#4984WhySoBad wants to merge 5 commits intorust-lang:masterfrom
getaddrinfo and freeaddrinfo shims#4984Conversation
|
Thank you for contributing to Miri! A reviewer will take a look at your PR, typically within a week or two. |
Can't we at least return something generic, like what our |
|
Yeah we can do that. |
|
Unlike And we also have the problem that Lines 249 to 260 in 3f8007e Are there any other shims which needed to circumvent this method? |
What are the errnums you are getting? |
|
Well, we only get a an The problem is that the |
|
Ah so the actual problem is that
There's no standard Unix errnum involved here ever, std just shoves this into an |
|
|
||
| let socket_addrs = match (node_str, port).to_socket_addrs() { | ||
| Ok(addrs) => addrs, | ||
| Err(e) => return this.set_last_error_and_return_i32(e), |
There was a problem hiding this comment.
So, this set_last_error_and_return_i32 call here doesn't really make sense. It means we return -1 on error but that's not how getaddrinfo works.
There was a problem hiding this comment.
Oh, I see, it shouldn't set errno but instead just return the negative integer instead. I've misread the man page. But the problem with unmapped error codes remains for #4987.
There was a problem hiding this comment.
Yeah, and also here we have the problem of even figuring out what to return. std hides the actual error code from us. We can just guess something but it's not great.
There was a problem hiding this comment.
Yes that's a problem. So should I just return something like EAI_FAIL because it's kind of a permanent failure?
There was a problem hiding this comment.
I was thinking EAI_SYSTEM and then set errno to the closest approximation of "we have no idea". Maybe EPROTO?
There was a problem hiding this comment.
Sounds reasonable. Maybe we should also emit a warning every time we return a bogus error such that it's clear that this wasn't the real error?
There was a problem hiding this comment.
Usually we only emit warnings the first time this happens, but that seems reasonable yeah.
|
No, we get standard UNIX error codes back -- they are just DNS specific: And the standard library has by far not all UNIX error codes mapped to |
These are not standard unix error codes. This is basically a separate error enum specifically for |
No, But that's only for "normal" host error codes, not for this other kind of error code that |
Hi,
This pull request adds shims for the
getaddrinfoandfreeaddrinfosyscalls. They are used by theToSocketAddrstrait in the standard library to resolve hostnames to socket addresses.Because the abstraction of the standard library is very tight, we're pretty much only able to shim the exact use case of the standard library.
Also, we cannot shim
gai_strerrorbecause the standard library doesn't haveErrorKinds for the DNS errors. This is a bit unfortunate because Miri will throw an unsupported error when there is a resolution error (e.g. hostname doesn't exist).