Bug 1421056

Summary: IPAddr eql? bug still present
Product: Red Hat Enterprise Linux 6 Reporter: Neil Wilson <neil>
Component: rubyAssignee: ruby maint <ruby-maint>
Status: CLOSED WONTFIX QA Contact: BaseOS QE - Apps <qe-baseos-apps>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6.8CC: vondruch
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-02-10 09:48:34 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Neil Wilson 2017-02-10 09:11:12 UTC
Description of problem:

When comparing IPAddr values with eql? you get the wrong result


Version-Release number of selected component (if applicable):

Name        : ruby
Arch        : x86_64
Version     : 1.8.7.374
Release     : 4.el6_6


How reproducible:


Steps to Reproduce:
1. ruby -ripaddr -e 'p IPAddr.new("192.168.1.0/30").eql?(IPAddr.new("192.168.1.0/30"))'

Actual results:

false


Expected results:

true

(which is what you see with ruby on RHEL 7)

Additional info:

eql? is missing in 1.8.7

This bug breaks array difference with arrays of IP addresses. Array difference uses 'eql?' under the hood rather than '=='

Comment 1 Vít Ondruch 2017-02-10 09:48:34 UTC
Neil, thank you for your ticket.

You are right, in this case, the example you provided compares if it is actually the same object, e.g.:

~~~
$ ruby -ripaddr -e 'ip = IPAddr.new("192.168.1.0/30"); p ip == ip'
~~~

which is not very useful in most cases. And this [1] seems to be the commit which "fixed" the behavior.

However, I am not sure it is worth of the change at this point, since:

1) The behavior was changed during Ruby 1.8.7 maintenance period, but it was never backported for Ruby 1.8.7 by upstream.

2) Also, considering RHEL6 release cycle, I don't see too much options to push this fix.

I am going to CLOSE WONTFIX the issue for now, but please don't hesitate to contact Red Hat support, so we might reconsider in case this turns to be important. Thank you.


[1] https://github.com/ruby/ruby/commit/61c11677c8ee20e07dea84a5a3bf8b68ff449188

Comment 2 Vít Ondruch 2017-02-10 09:51:50 UTC
Forgot to mention, that on RHEL6, you might consider to try Red Hat Software Collections, which provides more recent versions of Ruby.

Comment 3 Neil Wilson 2017-02-10 11:20:32 UTC
The workaround on array diff is fairly straightforward.

Rather than:

source - dest

do:

source.clone.delete_if {|e| dest.include? e}


This uses '==' equality rather than 'eql?' equality and it works as expected.