From: "nahi (Hiroshi Nakamura)" Date: 2012-07-02T09:13:21+09:00 Subject: [ruby-core:46092] [ruby-trunk - Feature #5654] Introduce global lock to avoid concurrent require Issue #5654 has been updated by nahi (Hiroshi Nakamura). > NOT received Fair because it's a regulation. I updated the slide at https://docs.google.com/presentation/d/1pXgUPtzoy4qFBznuuTSv0lzwmyoxUbxFyMk8GtzcXgI/edit Do you accept it now? ---------------------------------------- Feature #5654: Introduce global lock to avoid concurrent require https://bugs.ruby-lang.org/issues/5654#change-27699 Author: nahi (Hiroshi Nakamura) Status: Assigned Priority: Normal Assignee: nahi (Hiroshi Nakamura) Category: core Target version: 2.0.0 =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/