Bug #13735
Updated by junjihashimoto (Junji Hashimoto) almost 6 years ago
When we use multithreading environment, sortedset-initialization always fails. Reproducible programs and the logs are below. ~~~ ruby $ cat sortedset-test.rb require "set" def func1 set = SortedSet.new([2, 1, 5, 6, 4, 5, 3, 3, 3]) ary = [] set.each do |obj| ary << obj p ary end end def func2 set = SortedSet.new([2, 1, 5, 6, 4, 5, 3, 3, 3]) ary = [] set.each do |obj| ary << obj p ary end end puts "Started At #{Time.now}" t1 = Thread.new{func1()} t2 = Thread.new{func2()} t1.join t2.join puts "End at #{Time.now}" ~~~ ~~~ text $ ruby sortedset-test.rb Started At 2017-07-10 10:08:14 +0900 [1] [1, 2] [1, 2, 3] [1, 2, 3, 4] [1, 2, 3, 4, 5] [1, 2, 3, 4, 5, 6] /home/hogeuser/.rbenv/versions/2.4.1/lib/ruby/2.4.0/set.rb:711:in `remove_method': method `old_init' not defined in SortedSet (NameError) from /home/hogeuser/.rbenv/versions/2.4.1/lib/ruby/2.4.0/set.rb:711:in `block in setup' from /home/hogeuser/.rbenv/versions/2.4.1/lib/ruby/2.4.0/set.rb:709:in `module_eval' from /home/hogeuser/.rbenv/versions/2.4.1/lib/ruby/2.4.0/set.rb:709:in `setup' from /home/hogeuser/.rbenv/versions/2.4.1/lib/ruby/2.4.0/set.rb:719:in `initialize' from sortedset-test.rb:15:in `new' from sortedset-test.rb:15:in `func2' from sortedset-test.rb:26:in `block in <main>' ~~~ Following tickets may have a same problem. https://github.com/jubos/fake-s3/pull/55 https://github.com/synthetichealth/synthea/issues/156 Following link has initialization error of sortedset, too. But it does not use multithreading. https://stackoverflow.com/questions/41815930/ruby-marshal-load-doesnt-keep-order-of-sorted-set