Skip to content
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

Error code from getaddrinfo is lost #835

Open
Lupus opened this issue Jan 20, 2021 · 5 comments
Open

Error code from getaddrinfo is lost #835

Lupus opened this issue Jan 20, 2021 · 5 comments

Comments

@Lupus
Copy link

Lupus commented Jan 20, 2021

It seems that in case of getaddrinfo failure, the error is... lost?

if (job->result == 0) {

There is no "else" branch here. I get empty list from Lwt_unix.getaddrinfo and I'm trying to figure out why that happens.

@aantron
Copy link
Collaborator

aantron commented Jan 28, 2021

That does seem wrong @Lupus. I checked the standard Unix, and it looks like the Lwt code is directly based on it: https://github.com/ocaml/ocaml/blob/d14b3ec19f44fc4ac88c1fa4b7c97e201c689b96/otherlibs/unix/getaddrinfo.c#L117. It also doesn't have an else branch. Could you double-check using Unix?

I think we should add error handling. I also suggest to report the issue to the OCaml repo if you can confirm it, so we can get the benefit of any extra discussion from the OCaml team, and/or fix the (likely) bug there, as well.

@aantron
Copy link
Collaborator

aantron commented Jan 28, 2021

Well, one of the most immediate issues is that the EAI_* error codes are not included in type Unix.error.

@aantron
Copy link
Collaborator

aantron commented Jan 28, 2021

They do, however, appear in the POSIX man pages for the functions, e.g. https://man7.org/linux/man-pages/man3/freeaddrinfo.3p.html#ERRORS. So this could be an argument for adding them (eventually?). They are also present in libuv (http://docs.libuv.org/en/v1.x/errors.html#error-constants), which is part of why I forgot they are missing from Unix, at first.

@aantron
Copy link
Collaborator

aantron commented Jan 28, 2021

In the near term, we could map all of them to Unix.EUNKNOWNERR from Unix.error.

@Lupus
Copy link
Author

Lupus commented Jan 28, 2021

Could you double-check using Unix?

I don't have a minimal reproducible test case for that, I only see that sometimes I get exceptions from List.hd in production logs :) So I can't really check it with bare Unix.

In the near term, we could map all of them to Unix.EUNKNOWNERR from Unix.error

Probably we could get stringified message for EAI_* code and add it into one of string components of exception Unix_error of error * string * string? And raise it directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants