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

[Bug #20198] Make sure the correct error is raised for EAI_SYSTEM resolver fail #9628

Merged

Conversation

KJTsanaktsidis
Copy link
Contributor

In case of EAI_SYSTEM, getaddrinfo is supposed to set more detail in errno; however, because we call getaddrinfo on a thread now, and errno is threadlocal, that information is being lost. Instead, we just raise whatever errno happens to be on the calling thread (which can be something very confusing, like ECHILD).

Fix it by explicitly propagating errno back to the calling thread through the getaddrinfo_arg structure.

[Bug #20198]

@KJTsanaktsidis KJTsanaktsidis changed the title Make sure the correct error is raised for EAI_SYSTEM resolver fail [Bug #20198] Make sure the correct error is raised for EAI_SYSTEM resolver fail Jan 22, 2024
@mame
Copy link
Member

mame commented Jan 22, 2024

@KJTsanaktsidis Thanks! It looks good to me. I guess maybe we need to fix rb_getnameinfo too. Could you update it?

In case of EAI_SYSTEM, getaddrinfo is supposed to set more detail in
errno; however, because we call getaddrinfo on a thread now, and errno
is threadlocal, that information is being lost. Instead, we just raise
whatever errno happens to be on the calling thread (which can be
something very confusing, like `ECHILD`).

Fix it by explicitly propagating errno back to the calling thread
through the getaddrinfo_arg structure.

[Bug #20198]
@KJTsanaktsidis KJTsanaktsidis force-pushed the ktsanaktsidis/fix_resolver_echild branch from 085c189 to 75c7146 Compare January 22, 2024 02:47
@KJTsanaktsidis
Copy link
Contributor Author

Oh good catch, I didn't notice that method. I pushed up the fix to rb_getnameinfo as well.

@KJTsanaktsidis KJTsanaktsidis merged commit 6c0e58a into ruby:master Jan 22, 2024
96 checks passed
@KJTsanaktsidis KJTsanaktsidis deleted the ktsanaktsidis/fix_resolver_echild branch January 22, 2024 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants