Skip to content

[c-ares DNS resolver] Revert "Revert "[c-ares DNS resolver] Fix file descriptor use-after-close bug when c-ares writes succeed but subsequent read fails" (#33934)"#33942

Merged
apolcyn merged 3 commits intogrpc:masterfrom
apolcyn:rev_rev
Aug 1, 2023

Conversation

@apolcyn
Copy link
Copy Markdown
Contributor

@apolcyn apolcyn commented Aug 1, 2023

Rolls forward #33871

Second and third commits here fix internal build issues

In particular, add a // IWYU pragma: no_include <ares_build.h> since ares.h includes that anyways (and seems unlikely for that to change since it would be breaking)

@grpc-checks grpc-checks bot added the bloat/low label Aug 1, 2023
@apolcyn apolcyn requested a review from yijiem August 1, 2023 19:26
@apolcyn apolcyn removed the lang/c++ label Aug 1, 2023
@apolcyn apolcyn marked this pull request as ready for review August 1, 2023 19:30
@apolcyn apolcyn requested a review from markdroth as a code owner August 1, 2023 19:30
@apolcyn apolcyn merged commit e923706 into grpc:master Aug 1, 2023
@copybara-service copybara-service bot added the imported Specifies if the PR has been imported to the internal repository label Aug 1, 2023
apolcyn added a commit that referenced this pull request Aug 30, 2023
…l has data left in its read buffer (#34185)

If we get a readable event on an fd and both the following happens:

- c-ares does *not* read all bytes off the fd

- c-ares removes the fd from the set ARES_GETSOCK_READABLE

... then we have a busy loop here, where we'd keep asking c-ares to
process an fd that it no longer cares about.

This is indirectly related to a change in this code one month ago:
#33942 - before that change, c-ares
would close the socket when it called
[handle_error](https://github.com/c-ares/c-ares/blob/7f3262312f246556d8c1bdd8ccc1844847f42787/src/lib/ares_process.c#L707)
and so `IsFdStillReadableLocked` would start returning `false`, causing
us to get away with [this
loop](https://github.com/grpc/grpc/blob/f6a994229e72bc771963706de7a0cd8aa9150bb6/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc#L371).
Now, because `IsFdStillReadableLocked` will keep returning true (because
of our overridden `close` API), we'll loop forever.
apolcyn added a commit that referenced this pull request Sep 18, 2023
Now that we have #33942 (and another
follow-up [fix](#34185)), I think the
issue from #25289 is likely fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bloat/low imported Specifies if the PR has been imported to the internal repository lang/c++ lang/core per-call-memory/neutral per-channel-memory/neutral release notes: no Indicates if PR should not be in release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants