[#85940] [Ruby trunk Bug#14578] Forking a child process inside of a mutex crashes the ruby interpreter — ben.govero@...
Issue #14578 has been reported by bengovero (Ben Govero).
3 messages
2018/03/05
[#86205] [Ruby trunk Feature#14618] Add display width method to String for CLI — aycabta@...
Issue #14618 has been reported by aycabta (aycabta .).
3 messages
2018/03/19
[#86366] Re: [ruby-cvs:70102] usa:r63008 (trunk): get rid of test error/failure on Windows introduced at r62955 — Eric Wong <normalperson@...>
usa@ruby-lang.org wrote:
3 messages
2018/03/28
[ruby-core:85910] [Ruby trunk Bug#14573] rb_ary_or doesn't check objects hash when the array contains less than SMALL_ARRAY_LEN
From:
mail@...
Date:
2018-03-03 18:58:25 UTC
List:
ruby-core #85910
Issue #14573 has been reported by Willian (Willian van der Velde).
----------------------------------------
Bug #14573: rb_ary_or doesn't check objects hash when the array contains less than SMALL_ARRAY_LEN
https://bugs.ruby-lang.org/issues/14573
* Author: Willian (Willian van der Velde)
* Status: Open
* Priority: Normal
* Assignee:
* Target version:
* ruby -v: ruby 2.6.0dev (2017-12-27 trunk 61500) [x86_64-darwin17]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN, 2.5: UNKNOWN
----------------------------------------
Hello,
While debugging a build failure on a 2.5 branch of graphql-ruby (https://github.com/rmosolgo/graphql-ruby/pull/1303) we found out a difference in behavior for the Array's union operator.
On Ruby 2.5:
~~~ ruby
irb(main):001:0> class X; def initialize(h); @h = h; end; def hash; @h; end; def eql?(o); true; end; end
=> :eql?
irb(main):002:0> a = X.new(1) ; b = X.new(2)
=> #<X:0x00007fe0b00a4130 @h=2>
irb(main):003:0> a.hash
=> 1
irb(main):004:0> b.hash
=> 2
irb(main):005:0> [a] | [b]
=> [#<X:0x00007fe0b00a4158 @h=1>]
~~~
I would expect this union would result in two objects. On Ruby 2.3.6 I do get two objects:
~~~ ruby
irb(main):001:0> class X; def initialize(h); @h = h; end; def hash; @h; end; def eql?(o); true; end; end
=> :eql?
irb(main):002:0> a = X.new(1) ; b = X.new(2)
=> #<X:0x00007f816a80eec0 @h=2>
irb(main):003:0> a.hash
=> 1
irb(main):004:0> b.hash
=> 2
irb(main):005:0> [a] | [b]
=> [#<X:0x00007f816a80eee8 @h=1>, #<X:0x00007f816a80eec0 @h=2>]
~~~
I think this change is related to #13884, and it looks like when small arrays (less than SMALL_ARRAY_LEN) are given the object's hash isn't checked. If a bigger array is given we get a correct union:
~~~ ruby
irb(main):001:0> class X; def initialize(h); @h = h; end; def hash; @h; end; def eql?(o); true; end; end
=> :eql?
irb(main):002:0> a = 20.times.map { |i| X.new(i) }
=> ...
irb(main):003:0> b = 20.times.map { |i| X.new(100 + i) }
=> ...
irb(main):004:0> (a | b).size
=> 40
~~~
Thanks,
Willian
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>