Skip to content

Fix confusion of received response message#9

Merged
akr merged 1 commit intoruby:masterfrom
rhenium:ky/fix-dns-resp-handling
May 11, 2021
Merged

Fix confusion of received response message#9
akr merged 1 commit intoruby:masterfrom
rhenium:ky/fix-dns-resp-handling

Conversation

@rhenium
Copy link
Member

@rhenium rhenium commented Mar 26, 2021

This is a follow up for commit 33fb966 ("Remove sender/message_id pair after response received in resolv", 2020-09-11).

As the senders instance variable is also used for tracking transaction ID allocation, simply removing an entry without releasing the ID would eventually deplete the ID space and cause Resolv::DNS.allocate_request_id to hang.

It seems the intention of the code was to check that the received DNS message is actually the response for the question made within the method earlier. Let's have it actually does so.

[Bug #12838] https://bugs.ruby-lang.org/issues/12838
[Bug #17748] https://bugs.ruby-lang.org/issues/17748

This is a follow up for commit 33fb966 ("Remove sender/message_id
pair after response received in resolv", 2020-09-11).

As the @senders instance variable is also used for tracking transaction
ID allocation, simply removing an entry without releasing the ID would
eventually deplete the ID space and cause
Resolv::DNS.allocate_request_id to hang.

It seems the intention of the code was to check that the received DNS
message is actually the response for the question made within the method
earlier. Let's have it actually do so.

[Bug #12838] https://bugs.ruby-lang.org/issues/12838
[Bug #17748] https://bugs.ruby-lang.org/issues/17748
@cvx
Copy link

cvx commented Apr 8, 2021

Good work! 👏

Should a regression test be added for this change? (e.g. assert(Resolv::DNS::RequestID.empty?) after calling getresource())

Copy link
Member

@mame mame left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert in this area, but the change looks good to me.

eregon added a commit to eregon/truffleruby that referenced this pull request May 4, 2021
* The version of resolv.rb in 2.7.3 seem to have several problems:
  https://bugs.ruby-lang.org/issues/17748
  the fix is not released yet: ruby/resolv#9
  probably related:
  https://bugs.ruby-lang.org/issues/17658
  https://bugs.ruby-lang.org/issues/17781
eregon added a commit to eregon/truffleruby that referenced this pull request May 4, 2021
* The version of resolv.rb in 2.7.3 seem to have several problems:
  https://bugs.ruby-lang.org/issues/17748
  the fix is not released yet: ruby/resolv#9
  probably related:
  https://bugs.ruby-lang.org/issues/17658
  https://bugs.ruby-lang.org/issues/17781
@jsdalton
Copy link

jsdalton commented May 7, 2021

I filed an issue yesterday since we recently ran into exactly this. See #11 (I missed this PR when I opened the issue.)

I would +1 the suggestion for a unit test though, especially as the PR here effectively reverts the production code change from 33fb966 while leaving the test introduced in that commit in place. This indicates to me:

  • The test included in 33fb966 is either unrelated to the production code change or is itself incorrect (since removing the production code change does not cause the test to fail). Ah tested locally and I see the original test does fail.
  • This module is missing any tests to verify that request IDs are deallocated after use. Since the implementation allows for only a 64k space (stored in a global variable) I would expect strong guarantees of deallocation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants