Skip to content

concurrent-ruby rspec testsuite fails with ruby4.0.0dev perhaps due to Set change #1093

Description

@mtasaka

Trying with ruby 4.0.0dev (2025-11-16 master bacd35626c) +PRISM [x86_64-linux]
ruby/ruby@bacd356

concurrent-ruby git head
05523c0
concurrent-ruby side rspec testsuite fails (concurrent-ruby-edge side not tested) like:

$ env RUBYLIB=$(pwd)/lib/concurrent-ruby rspec --exclude-pattern 'spec/concurrent/{actor_spec.rb,channel_spec.rb,lazy_register_spec.rb,channel/**/*,edge/**/*,processing_actor_spec.rb,promises_spec.rb,throttle_spec.rb,cancellation_spec.rb,executor/wrapping_executor_spec.rb}'

......
Failures:

  1) Concurrent::Set.[] when initializing with arguments creates a set with the given objects
     Failure/Error: monitor or raise("BUG: Internal monitor was not properly initialized. Please report this to the concurrent-ruby developers.")
     
     RuntimeError:
       BUG: Internal monitor was not properly initialized. Please report this to the concurrent-ruby developers.
     # ./lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb:34:in 'Concurrent::CRubySet#=='
     # ./spec/concurrent/set_spec.rb:17:in 'block (4 levels) in <module:Concurrent>'

  2) Concurrent::Set.[] when initializing with no arguments is expected to be empty
     Failure/Error: monitor or raise("BUG: Internal monitor was not properly initialized. Please report this to the concurrent-ruby developers.")
     
     RuntimeError:
       BUG: Internal monitor was not properly initialized. Please report this to the concurrent-ruby developers.
     # ./lib/concurrent-ruby/concurrent/thread_safe/util/data_structures.rb:34:in 'Concurrent::CRubySet#empty?'
     # ./spec/concurrent/set_spec.rb:11:in 'block (4 levels) in <module:Concurrent>'

Finished in 2 minutes 31.1 seconds (files took 0.48868 seconds to load)
2157 examples, 2 failures, 12 pending

Failed examples:

rspec ./spec/concurrent/set_spec.rb:16 # Concurrent::Set.[] when initializing with arguments creates a set with the given objects
rspec ./spec/concurrent/set_spec.rb:10 # Concurrent::Set.[] when initializing with no arguments is expected to be empty

Maybe this is due to Set change in ruby4_0 like
ruby/ruby@e4f85bf
but I am not sure.

Activity

  1. eregon commented on Nov 17, 2025

    @eregon
    Member

    Thanks for the report, indeed I can repro with be rake clean compile && be rspec spec/concurrent/set_spec.rb.

  2. eregon commented on Nov 17, 2025

    @eregon
    Member

    https://bugs.ruby-lang.org/issues/21375#note-8 I think this should be fixed in CRuby.

  3. eregon commented on Nov 17, 2025

    @eregon
    Member

    BTW using ::Set in

    when Concurrent.on_cruby?
    on Ruby 4+ doesn't work, because CRuby forbids adding elements while iterating:

    irb(main):001> set = Set.new
    => Set[]
    irb(main):002> Thread.new { loop { set.each {} } }
    => #<Thread:0x00007f63adedea00 (irb):2 run>
    irb(main):003> set.add 1
    => Set[1]
    irb(main):004> set.add 2
    (irb):4:in 'Set#add': can't add a new item into set during iteration (RuntimeError)
    	from (irb):4:in '<main>'
    	from /home/eregon/.rubies/ruby-dev/lib/ruby/gems/4.0.0+0/gems/irb-1.15.3/exe/irb:9:in '<top (required)>'
    	from /home/eregon/.rubies/ruby-dev/lib/ruby/4.0.0+0/rubygems.rb:303:in 'Kernel#load'
    	from /home/eregon/.rubies/ruby-dev/lib/ruby/4.0.0+0/rubygems.rb:303:in 'Gem.activate_and_load_bin_path'
    	from /home/eregon/.rubies/ruby-dev/bin/irb:25:in '<main>'

    And that's behavior relied on, notably shown by #900 (and this behavior even has always been the case on non-CRuby implementations).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions