From: Charles Oliver Nutter Date: 2008-12-23T04:50:30+09:00 Subject: [ruby-core:20805] Re: [Bug #920] require is not thread-safe Robert Klemme wrote: >> The first solution will not be thread safe, for the reasons stated���the fact >> that require returns does not mean that the file is actually loaded. This >> would lead to hard-to-diagnose problems. > > Absolutely, I think this is not really a solution. Well, by definition it's not a solution because it doesn't actually solve concurrent requires. It's just the minimum we change we need to agree upon, and it's what I've done in JRuby so far. But it's also the recommended fix in the absence of a solution. It hurts when I do this, doctor... >> I think the global lock is the way to go. And I find it hard to come up with >> any code this could currently break. > > Please see my reply (link below) where I constructed a deadlock. > Granted, you need to be able to create threads when holding the > require lock - so if that is forbidden all is well. But the lock > alone is not enough. > > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/20802 I stand by my assertion that there's no way to fix this if we allow required files to themselves launch threads that do additional requires. That needs to be verboten or the whole thing comes crashing down. - Charlie