Bug 1421056 - IPAddr eql? bug still present
Summary: IPAddr eql? bug still present
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: ruby
Version: 6.8
Hardware: Unspecified
OS: Unspecified
Target Milestone: rc
: ---
Assignee: ruby maint
QA Contact: BaseOS QE - Apps
Depends On:
TreeView+ depends on / blocked
Reported: 2017-02-10 09:11 UTC by Neil Wilson
Modified: 2017-02-10 11:20 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Last Closed: 2017-02-10 09:48:34 UTC
Target Upstream Version:

Attachments (Terms of Use)

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     :
Release     : 4.el6_6

How reproducible:

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

Actual results:


Expected results:


(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(""); 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


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

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

Note You need to log in before you can comment on or make changes to this bug.