From: nagachika00@... Date: 2018-03-25T04:20:45+00:00 Subject: [ruby-core:86286] [Ruby trunk Bug#14571] File descriptor leak in resolv.rb Issue #14571 has been updated by nagachika (Tomoyuki Chikanaga). Backport changed from 2.2: REQUIRED, 2.3: REQUIRED, 2.4: REQUIRED to 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE ruby_2_4 r62915 merged revision(s) 62671. ---------------------------------------- Bug #14571: File descriptor leak in resolv.rb https://bugs.ruby-lang.org/issues/14571#change-71199 * Author: quixoten (Devin Christensen) * Status: Closed * Priority: Normal * Assignee: * Target version: * ruby -v: * Backport: 2.2: REQUIRED, 2.3: REQUIRED, 2.4: DONE ---------------------------------------- There's an edge case in resolv.rb that can lead to file descriptor leaks on a highly saturated system (logstash in our case). ![file-descriptor-leak](https://user-images.githubusercontent.com/63675/36873892-3507d282-1d67-11e8-9912-3ba58a287b5b.png) (the cliff at the end is from a restart of the application) We're using the logstash-filter-dns plugin which [uses timeout](https://github.com/logstash-plugins/logstash-filter-dns/blob/v3.0.7/lib/logstash/filters/dns.rb#L250-L252). When a timeout fires while [waiting](https://github.com/ruby/ruby/blob/8032b00f8e43be6e34f93005a17e26bc6d89f1c1/lib/resolv.rb#L649-L658) for a [random](https://github.com/ruby/ruby/blob/8032b00f8e43be6e34f93005a17e26bc6d89f1c1/lib/resolv.rb#L752) [port](https://github.com/ruby/ruby/blob/8032b00f8e43be6e34f93005a17e26bc6d89f1c1/lib/resolv.rb#L805), the new object is never returned to the caller. Instead `requester` is [set to nil](https://github.com/ruby/ruby/blob/8032b00f8e43be6e34f93005a17e26bc6d89f1c1/lib/resolv.rb#L514). 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. (This if my first patch submission, let me know what I can fix or do better.) ---Files-------------------------------- add-failing-tests.patch (1.39 KB) fix-leak.patch (5.01 KB) combined.patch (6.4 KB) -- https://bugs.ruby-lang.org/ Unsubscribe: