From: eregontp@... Date: 2018-08-16T13:21:53+00:00 Subject: [ruby-core:88504] [Ruby trunk Feature#15000] Prevent to initialize MonitorMixin twice Issue #15000 has been reported by Eregon (Benoit Daloze). ---------------------------------------- Feature #15000: Prevent to initialize MonitorMixin twice https://bugs.ruby-lang.org/issues/15000 * Author: Eregon (Benoit Daloze) * Status: Open * Priority: Normal * Assignee: shugo (Shugo Maeda) * Target version: ---------------------------------------- Some libraries or tests unfortunately do something like: ~~~ ruby require 'monitor' class Foo include MonitorMixin def initialize(*args) super() mon_initialize end end ~~~ This unfortunately ends up initializing the monitor twice. If the two monitor initializations are done concurrently, we can end up with two threads entering the same Monitor concurrently, as they can acquire two different Mutex instances. I'd proposed to raise an exception if `@mon_mutex` is already set, like `raise "already initialized" if @mon_mutex`. This doesn't fully solve the problem if allocate is used and #initialize is called concurrently, but then I think it's the user's fault. I originally found this problem while running Rails tests, but I can't find the exact source file anymore causing this. Still, I think it's better to check here. -- https://bugs.ruby-lang.org/ Unsubscribe: