Bug #8374
race condition when two threads require a gem
Description
=begin
Requiring a gem with a C extension seems to be not threadsafe.
Any one of the require lines below will frequently (but not always) cause an error like the following:
/usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in require': cannot load such file -- sqlite3 (LoadError)
require'
from /usr/local/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in
from thread.rb:7:in `block (2 levels) in '
Using one thread avoids the problem.
ths = (1..2).map do
Thread.new do
# require 'msgpack'
# require 'yajl'
# require 'sequel'
# require 'nio4r'
require 'sqlite3'
end
end
ths.each {|th| th.join}
=end
History
#1
[ruby-core:54844]
Updated by nobu (Nobuyoshi Nakada) almost 5 years ago
- Description updated (diff)
- Category set to lib
- Status changed from Open to Assigned
- Assignee set to drbrain (Eric Hodel)
Seems rubygems specific.
#2
[ruby-core:55789]
Updated by drbrain (Eric Hodel) almost 5 years ago
- Subject changed from race condition when two threads require a gem with a C extension to race condition when two threads require a gem
This is reproducible without a C extension, updated subject.
#3
[ruby-core:55862]
Updated by drbrain (Eric Hodel) almost 5 years ago
- Status changed from Assigned to Closed
This has been fixed in rubygems master and 2.0 branches.