Fix file descriptor leak in resolv.rb#5074
Merged
headius merged 5 commits intojruby:masterfrom Mar 20, 2018
Merged
Conversation
Member
|
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. |
Member
|
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. |
Contributor
Author
|
I'll work on getting it submitted to CRuby. |
Contributor
Author
Contributor
Author
|
The patch was accepted into CRuby. Should this be closed now? |
Member
|
We'll merge it in, thanks! |
Member
|
It doesn't appear they have committed this to their 2.5 branch yet, so I'll merge to our fork for now. |
headius
added a commit
to jruby/ruby
that referenced
this pull request
Mar 20, 2018
headius
added a commit
to jruby/ruby
that referenced
this pull request
Mar 20, 2018
Member
|
Once there's a backport for 2.3 we can add this to JRuby 9.1.17. |
jsvd
referenced
this pull request
Jun 8, 2018
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.
This was referenced Dec 11, 2018
Contributor
Author
|
Looks like this made it into 2.3. Would it be possible to add this to a 9.1.17 release? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
requesteris 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.