Actions
Bug #13735
closedInitialization-error of sortedset
Description
When we use multithreading environment, sortedset-initialization always fails.
Reproducible programs and the logs are below.
$ 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}"
$ 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
Updated by junjihashimoto (Junji Hashimoto) almost 8 years ago
- Description updated (diff)
Updated by junjihashimoto (Junji Hashimoto) almost 8 years ago
- Subject changed from Initializing error of sortedset to Initialization-error of sortedset
Updated by knu (Akinori MUSHA) almost 8 years ago
- Status changed from Open to Assigned
- Assignee set to knu (Akinori MUSHA)
Updated by knu (Akinori MUSHA) over 7 years ago
- Status changed from Assigned to Closed
Applied in changeset trunk|r60304.
Use a mutex to make SortedSet.setup thread-safe
This should fix [Bug #13735].
Actions
Like0
Like0Like0Like0Like0