Project

General

Profile

Actions

Bug #9477

closed

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

Added by bjoern (Bjoern Rennhak) almost 11 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.1.0p0 (2013-12-25 revision 44422) [x86_64-linux]
[ruby-core:60442]

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

Updated by drbrain (Eric Hodel) almost 11 years ago

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

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.

Updated by akr (Akira Tanaka) almost 11 years 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.)

Updated by bjoern (Bjoern Rennhak) almost 11 years 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>'


Updated by bjoern (Bjoern Rennhak) almost 11 years 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)

Updated by akr (Akira Tanaka) almost 11 years ago

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

Updated by bjoern (Bjoern Rennhak) almost 11 years 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.

Updated by akr (Akira Tanaka) almost 11 years ago

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

Applied in changeset r44880.


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

Updated by akr (Akira Tanaka) almost 11 years 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.

Updated by drbrain (Eric Hodel) almost 11 years ago

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

Updated by usa (Usaku NAKAMURA) almost 11 years 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

Updated by usa (Usaku NAKAMURA) almost 11 years 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.

Updated by nagachika (Tomoyuki Chikanaga) almost 11 years 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.

Updated by naruse (Yui NARUSE) almost 11 years 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

Actions #14

Updated by l33tname (Sir l33tname) over 9 years 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.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0