Bug #9498
closedundefined method 'ord' for nil:NilClass from Resolv methods when internet connection is lost
Description
We experienced the following exception from a call to Resolv.getaddresses during a time when our local DNS resolver was available but the site's internet connection was cut off:
undefined method 'ord' for nil:NilClass
/usr/lib/ruby/2.0.0/resolv.rb:1542:in 'get_labels'
/usr/lib/ruby/2.0.0/resolv.rb:1535:in 'get_name'
/usr/lib/ruby/2.0.0/resolv.rb:1568:in 'get_question'
/usr/lib/ruby/2.0.0/resolv.rb:1446:in 'block (2 levels) in decode'
/usr/lib/ruby/2.0.0/resolv.rb:1445:in 'each'
/usr/lib/ruby/2.0.0/resolv.rb:1445:in 'block in decode'
/usr/lib/ruby/2.0.0/resolv.rb:1470:in 'initialize'
/usr/lib/ruby/2.0.0/resolv.rb:1434:in 'new'
/usr/lib/ruby/2.0.0/resolv.rb:1434:in 'decode'
/usr/lib/ruby/2.0.0/resolv.rb:684:in 'request'
/usr/lib/ruby/2.0.0/resolv.rb:521:in 'block in each_resource'
/usr/lib/ruby/2.0.0/resolv.rb:1055:in 'block (3 levels) in resolv'
/usr/lib/ruby/2.0.0/resolv.rb:1053:in 'each'
/usr/lib/ruby/2.0.0/resolv.rb:1053:in 'block (2 levels) in resolv'
/usr/lib/ruby/2.0.0/resolv.rb:1052:in 'each'
/usr/lib/ruby/2.0.0/resolv.rb:1052:in 'block in resolv'
/usr/lib/ruby/2.0.0/resolv.rb:1050:in 'each'
/usr/lib/ruby/2.0.0/resolv.rb:1050:in 'resolv'
/usr/lib/ruby/2.0.0/resolv.rb:513:in 'each_resource'
/usr/lib/ruby/2.0.0/resolv.rb:406:in 'each_address'
/usr/lib/ruby/2.0.0/resolv.rb:115:in 'block in each_address'
/usr/lib/ruby/2.0.0/resolv.rb:114:in 'each'
/usr/lib/ruby/2.0.0/resolv.rb:114:in 'each_address'
/usr/lib/ruby/2.0.0/resolv.rb:101:in 'getaddresses'
/usr/lib/ruby/2.0.0/resolv.rb:50:in 'getaddresses'
Perhaps @data is empty at this point?
This does not appear to be a new issue as I found https://github.com/ioquatix/rubydns/issues/20 which seems to be the same error (but on 1.9).