Skip to content

Array#slice! broken on Rubinius #559

@toroidal-code

Description

@toroidal-code

Expected behavior:

Array#slice! returns a fully-functional Array (intuitively a Concurrent::Array) containing the data removed from the primary array.

Actual behavior:

Array#slice! returns a near-complete version of Array, but with no valid @_monitor, thus causing any methods that require synchronization on the object to fail.

Example:

~ ❯❯❯ uname -a
Linux 4.6.4-1-ARCH #1 SMP PREEMPT Mon Jul 11 19:12:32 CEST 2016 x86_64 GNU/Linux
~ ❯❯❯ ruby --version
rubinius 3.47 (2.3.1 43e411b2 2016-07-15 3.8.0) [x86_64-linux-gnu]
~ ❯❯❯ pry
[1] pry(main)> require 'concurrent/array'
=> true
[2] pry(main)> a = Concurrent::Array.new [1,2,3,4,5,6]
=> [1, 2, 3, 4, 5, 6]
[3] pry(main)> a.instance_variable_get :@_monitor
=> #<Monitor:0x98b30 @mon_count=0, @mon_mutex=#<Mutex:0x98c28 @owner=nil>, @mon_owner=nil>
[4] pry(main)> b = a.slice!(0..2)
=> #<Concurrent::Array:0x4c7d4>
[5] pry(main)> puts b
NoMethodError: undefined method `synchronize' on nil:NilClass.
from core/zed.rb:1425:in `synchronize (method_missing)'
[6] pry(main)> b.instance_variable_get :@_monitor
=> nil

I honestly have no idea what's going on with this. I tested a few other things, and it looks like #slice! and indexing with a range (e.g. a[0..2]) both return invalid Concurrent::Arrays. My first thought from looking in thread_safe/util/array_hash_rbx.rb is that _mon_initialize isn't being called when it should be, but I don't know.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA bug in the library or documentation.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions