Bug #6867
closedsuper in a Mutex#synchronize block
Description
The following code:
require 'thread'
class Parent
def meth
end
end
class Child < Parent
def meth
Mutex.new.synchronize do
super
end
end
end
Child.new.meth
raises
bug_super.rb:13:in block in meth': can't find the method for super, which may be called in an orphan block (NoMethodError) from <internal:prelude>:10:in
synchronize'
from bug_super.rb:12:in meth' from bug_super.rb:18:in
'
I met the bug with the listen gem: https://github.com/guard/listen/blob/master/lib/listen/adapters/darwin.rb#L22-25 .
Files
Updated by nagachika (Tomoyuki Chikanaga) over 12 years ago
Hi,
This issue seems happen after r36640.
Updated by tenderlovemaking (Aaron Patterson) about 12 years ago
I'm hitting this bug in the Rails tests too. It does not need to be a synchronize block. Any method that yields will cause this error:
class A; def self.yielder; yield; end end
class X
def self.hello; 'hi'; end
end
class Y < X
def self.hello; A.yielder { super() }; end
end
Y.hello
I've attached a patch with a test and fix. It seems that the loop that walks up the control frames would stop even though there is a valid recipient for that method further up the stack. I'm not incredibly pleased with my patch because it has to do a kind_of
for each object as it walks up, but it does fix this bug.
Shugo - do you have a better fix for this, or may I apply this patch?
Thanks.
Updated by shugo (Shugo Maeda) about 12 years ago
- Status changed from Open to Assigned
- Assignee changed from shugo (Shugo Maeda) to tenderlovemaking (Aaron Patterson)
tenderlovemaking (Aaron Patterson) wrote:
Shugo - do you have a better fix for this, or may I apply this patch?
I haven't come up with a better solution. Could you apply the patch?
Updated by mame (Yusuke Endoh) over 11 years ago
- Status changed from Assigned to Closed
The patch was applied at r36784.
--
Yusuke Endoh mame@tsg.ne.jp