From: "mame (Yusuke Endoh)" Date: 2012-11-24T08:35:23+09:00 Subject: [ruby-core:49909] [ruby-trunk - Feature #5654] Introduce global lock to avoid concurrent require Issue #5654 has been updated by mame (Yusuke Endoh). Target version changed from 2.0.0 to next minor ---------------------------------------- Feature #5654: Introduce global lock to avoid concurrent require https://bugs.ruby-lang.org/issues/5654#change-33668 Author: nahi (Hiroshi Nakamura) Status: Assigned Priority: Normal Assignee: nahi (Hiroshi Nakamura) Category: core Target version: next minor =begin Current implementation of "require" has locks for each file (expanded name from required feature) and serializes file loading from Threads. The first Thread acquires the lock for the file and starts loading. The second Thread waits for acquiring the lock, and when the first Thread release the lock, it acquires the lock, then returns immediately. This can cause deadlock by cross-require from Threads. And code that does not properly use "require" could meet several problems; * constants can be defined before they're ready for use * classes can be modified while they're being used * global state can be initialized at the same time it's in use Proposal: introduce global (per VM) lock to avoid concurrent file loading by "require" so that only one Thread can call "require" at the same time. I don't have pros/cons list at this moment. Let's discuss it, too. Derived from a discussion at #5621 (thread-safe autoload) =end -- http://bugs.ruby-lang.org/