Files
grpc/test/cpp/naming
apolcyn 76203ba589 [c-ares DNS resolver] Fix file descriptor use-after-close bug when c-ares writes succeed but subsequent read fails (#33871)
Normally, c-ares related fds are destroyed after all DNS resolution is
finished in [this code
path](https://github.com/grpc/grpc/blob/c82d31677aeea66c128a5b912ad87efcd5f74d67/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc#L210).
Also there are some fds that c-ares may fail to open or write to
initially, and c-ares will close them internally before grpc ever knows
about them.

But if:
1) c-ares opens a socket and successfully writes a request on it
2) then a subsequent read fails

Then c-ares will close the fd in [this code
path](https://github.com/c-ares/c-ares/blob/bad62225b7f6b278b92e8e85a255600b629ef517/src/lib/ares_process.c#L740),
but gRPC will have a reference on the fd and will still use it
afterwards.

Fix here is to leverage the c-ares socket-override API to properly track
fd ownership between c-ares and grpc.

Related: internal issue b/292203138
2023-07-31 12:25:38 -07:00
..