-
-
Notifications
You must be signed in to change notification settings - Fork 923
Fix file descriptor leak in resolv.rb #5074
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
Conversation
Great find! We just ship CRuby's resolv.rb...so it seems likely they'd be affected too. I'll have a look at your patches. |
Ok yeah, I am pretty sure CRuby would be affected by this as well. We need to submit this to them as a patch with backports to 2.3. |
I'll work on getting it submitted to CRuby. |
The patch was accepted into CRuby. Should this be closed now? |
We'll merge it in, thanks! |
It doesn't appear they have committed this to their 2.5 branch yet, so I'll merge to our fork for now. |
Once there's a backport for 2.3 we can add this to JRuby 9.1.17. |
While d1a760e fixed handling of compressed IPv6 addresses, it also broke the "freeing" part of it. Currently every DNS request leaks single request id: ``` require 'resolv' Resolv::DNS::RequestID.values.map(&:length) Resolv::DNS.new.getaddress('example.com') Resolv::DNS::RequestID.values.map(&:length) ``` Given the fact that request ids are chosen from `0x0000..0xffff` range - the app can issue 65535 requests and then will be blocked forever trying to allocate another one. This commit makes request id caching work by using same data for allocation and freeing.
Looks like this made it into 2.3. Would it be possible to add this to a 9.1.17 release? |
There's an edge case in resolv.rb that can lead to file descriptor leaks on a highly saturated system (logstash in our case).
(the cliff at the end is from a restart of logstash)
We're using the logstash-filter-dns plugin which uses timeout.
When a timeout fires while waiting for a random port, the new object is never returned to the caller. Instead
requester
is set to nil. There's no handle to any sockets that were created in the initializer, so they can't be closed, and one ore more file descriptors is leaked.