Bug #9477

Address family not supported by protocol - socket(2) - udp

Added by Bjoern Rennhak about 1 year ago. Updated about 17 hours ago.

[ruby-core:60442]
Status:Closed
Priority:Normal
Assignee:-
ruby -v:ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux] Backport:1.9.3: DONE, 2.0.0: DONE, 2.1: DONE

Description

On a fresh Debian GNU/Linux VServer guest running the latest RVM HEAD I experienced the following error:

Exception `LoadError' at /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:169 - LoadError
Exception `Errno::EAFNOSUPPORT' at /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:744 - Address family not supported by protocol - socket(2) - udp
ERROR: While executing gem ... (Errno::EAFNOSUPPORT)
Address family not supported by protocol - socket(2) - udp

(Please see gist below for entire stacktrace).

After discussion on irc.freenode.org #rvm with mpapis (rvm maintainer) it turns out

 rvm rubygems latest-2.0

fixes the issue. rvm rubygems head did not work.

Not quite sure what went wrong here and if this affects anyone who isn't running vserver.

Reference:

https://gist.github.com/anonymous/483c42ce132495271fc2
https://github.com/rubygems/rubygems/issues/803#issuecomment-33835128

Associated revisions

Revision 44880
Added by Akira Tanaka about 1 year ago

  • lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on socket creation. Reported by Bjoern Rennhak. [Bug #9477]

Revision 44880
Added by Akira Tanaka about 1 year ago

  • lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on socket creation. Reported by Bjoern Rennhak. [Bug #9477]

History

#1 Updated by Eric Hodel about 1 year ago

  • Tracker changed from Backport to Bug
  • Project changed from Backport21 to Ruby trunk

What is the output of:

ruby -rresolv -e 'puts Resolv::DNS.new.getresource("_rubygems._tcp.rubygems.org", Resolv::DNS::Resource::IN::SRV).target'

This is the code in the backtrace listed above.

#2 Updated by Akira Tanaka about 1 year ago

Does the host supports IPv6?
(I guess it doesn't because vserver needs a patch to use IPv6: http://linux-vserver.org/IPv6 )

Would you please show us /etc/resolv.conf.
(I guess it contains IPv6 address for some reason.)

#3 Updated by Bjoern Rennhak about 1 year ago

~% ruby -rresolv -e 'puts Resolv::DNS.new.getresource("_rubygems._tcp.rubygems.org", Resolv::DNS::Resource::IN::SRV).target'

Output is

/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:744:in `initialize': Address family not supported by protocol - socket(2) - udp (Errno::EAFNOSUPPORT)
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:744:in `new'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:744:in `block in initialize'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:735:in `each'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:735:in `initialize'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:561:in `new'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:561:in `make_udp_requester'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:517:in `fetch_resource'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:510:in `each_resource'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:491:in `getresource'

With -rdebug and stepping though it, I additionally get this.

% ruby -rresolv -e 'puts Resolv::DNS.new.getresource("_rubygems._tcp.rubygems.org", Resolv::DNS::Resource::IN::SRV).target'
N::SRV).target'
Debug.rb
Emacs support available.

/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57:        RUBYGEMS_ACTIVATION_MONITOR.enter
(rdb:1) c
/usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:744:in `initialize': Address family not supported by protocol - socket(2) - udp (Errno::EAFNOSUPPORT)
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:744:in `new'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:744:in `block in initialize'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:735:in `each'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:735:in `initialize'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:561:in `new'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:561:in `make_udp_requester'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:517:in `fetch_resource'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:510:in `each_resource'
        from /usr/local/rvm/rubies/ruby-2.1.0/lib/ruby/2.1.0/resolv.rb:491:in `getresource'
        from -e:1:in `<main>'


#4 Updated by Bjoern Rennhak about 1 year ago

No, vserver doesn't have the ipv6 patch enabled. Hosts is

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

Even after removing all ipv6 entries and restarting vserver guest, error still persists.

127.0.0.1       localhost

(current /etc/hosts)

#5 Updated by Akira Tanaka about 1 year ago

Please show us /etc/resolv.conf, not /etc/hosts.

#6 Updated by Bjoern Rennhak about 1 year ago

Sorry for that, misread it.

% cat /etc/resolv.conf 
nameserver 213.133.99.99
nameserver 213.133.100.100
nameserver 213.133.98.98
nameserver 2a01:4f8:0:a111::add:9898
nameserver 2a01:4f8:0:a102::add:9999
nameserver 2a01:4f8:0:a0a1::add:1010

After commenting the ipv6 lines, and re-running ruby -rresolv -e 'puts Resolv::DNS.new.getresource("_rubygems._tcp.rubygems.org", Resolv::DNS::Resource::IN::SRV).target'
I get correct output api.rubygems.org without any errors.

So it seems, due to automatic resolv.conf getting ipv6 entries from datacenter provider but vserver missing ipv6 patch, this error occurs. Hence its a configuration issue and not a Ruby bug.

Apologies for the hassle and thank you for the help.

#7 Updated by Akira Tanaka about 1 year ago

  • % Done changed from 0 to 100
  • Status changed from Open to Closed

Applied in changeset r44880.


  • lib/resolv.rb: Ignore name servers which cause EAFNOSUPPORT on socket creation. Reported by Bjoern Rennhak. [Bug #9477]

#8 Updated by Akira Tanaka about 1 year ago

Thank you.
resolv.conf contains IPv6 address.
So resolv.rb try to create an IPv6 socket but vserver linux kernel return the error.

I committed r44880 on trunk to ignore name servers which is impossible to create a socket.
I hope it solves this issue.
I didn't test the patch because I can't reproduce the problem, though.

#9 Updated by Eric Hodel about 1 year ago

  • Backport set to 1.9.3: UNKNOWN, 2.0.0: REQUIRED, 2.1: REQUIRED

#10 Updated by Usaku NAKAMURA about 1 year ago

  • Backport changed from 1.9.3: UNKNOWN, 2.0.0: REQUIRED, 2.1: REQUIRED to 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: REQUIRED

#11 Updated by Usaku NAKAMURA about 1 year ago

  • Backport changed from 1.9.3: REQUIRED, 2.0.0: REQUIRED, 2.1: REQUIRED to 1.9.3: DONE, 2.0.0: REQUIRED, 2.1: REQUIRED

backported into ruby_1_9_3 at r44949.

#12 Updated by Tomoyuki Chikanaga about 1 year ago

  • Backport changed from 1.9.3: DONE, 2.0.0: REQUIRED, 2.1: REQUIRED to 1.9.3: DONE, 2.0.0: DONE, 2.1: REQUIRED

r44880 was backported to ruby_2_0_0 at r44977.

#13 Updated by Yui NARUSE about 1 year ago

  • Backport changed from 1.9.3: DONE, 2.0.0: DONE, 2.1: REQUIRED to 1.9.3: DONE, 2.0.0: DONE, 2.1: DONE

r45110

#14 Updated by Sir l33tname about 17 hours ago

I guess it's not really fixed I can reproduce a bug which looks for me very similar (I guess it's the same problem)

Ruby 2.2

root@l33t:~ # ruby22 --version
ruby 2.2.2p95 (2015-04-13 revision 50295) [amd64-freebsd10]
root@l33t:~ # ruby22 -rresolv -e 'puts Resolv::DNS.new.getresource("_rubygems._tcp.rubygems.org", Resolv::DNS::Resource::IN::SRV).target'
/usr/local/lib/ruby/2.2/resolv.rb:747:in `initialize': Protocol not supported - socket(2) - udp (Errno::EPROTONOSUPPORT)
    from /usr/local/lib/ruby/2.2/resolv.rb:747:in `new'
    from /usr/local/lib/ruby/2.2/resolv.rb:747:in `block in initialize'
    from /usr/local/lib/ruby/2.2/resolv.rb:737:in `each'
    from /usr/local/lib/ruby/2.2/resolv.rb:737:in `initialize'
    from /usr/local/lib/ruby/2.2/resolv.rb:561:in `new'
    from /usr/local/lib/ruby/2.2/resolv.rb:561:in `make_udp_requester'
    from /usr/local/lib/ruby/2.2/resolv.rb:516:in `fetch_resource'
    from /usr/local/lib/ruby/2.2/resolv.rb:509:in `each_resource'
    from /usr/local/lib/ruby/2.2/resolv.rb:490:in `getresource'
    from -e:1:in `<main>'

Ruby 2.1

root@l33t:~ # ruby --version
ruby 2.1.6p336 (2015-04-13 revision 50298) [amd64-freebsd10]
root@l33t:~ # ruby -rresolv -e 'puts Resolv::DNS.new.getresource("_rubygems._tcp.rubygems.org", Resolv::DNS::Resource::IN::SRV).target'
/usr/local/lib/ruby/2.1/resolv.rb:748:in `initialize': Protocol not supported - socket(2) - udp (Errno::EPROTONOSUPPORT)
    from /usr/local/lib/ruby/2.1/resolv.rb:748:in `new'
    from /usr/local/lib/ruby/2.1/resolv.rb:748:in `block in initialize'
    from /usr/local/lib/ruby/2.1/resolv.rb:738:in `each'
    from /usr/local/lib/ruby/2.1/resolv.rb:738:in `initialize'
    from /usr/local/lib/ruby/2.1/resolv.rb:562:in `new'
    from /usr/local/lib/ruby/2.1/resolv.rb:562:in `make_udp_requester'
    from /usr/local/lib/ruby/2.1/resolv.rb:517:in `fetch_resource'
    from /usr/local/lib/ruby/2.1/resolv.rb:510:in `each_resource'
    from /usr/local/lib/ruby/2.1/resolv.rb:491:in `getresource'
    from -e:1:in `<main>'

As you can see I run it on FreeBSD, inside a jail.

Also available in: Atom PDF