Forum: Ruby-core [ruby-trunk - Bug #6867][Open] super in a Mutex#synchronize block

Posted by Eregon (Benoit Daloze) (Guest)
on 2012-08-14 13:46
(Received via mailing list)
Issue #6867 has been reported by Eregon (Benoit Daloze).

----------------------------------------
Bug #6867: super in a Mutex#synchronize block
https://bugs.ruby-lang.org/issues/6867

Author: Eregon (Benoit Daloze)
Status: Open
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-08-14 trunk 36700) [x86_64-darwin10.8.0]


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 `<main>'

I met the bug with the listen gem: 
https://github.com/guard/listen/blob/master/lib/li... 
.
Posted by nagachika (Tomoyuki Chikanaga) (Guest)
on 2012-08-14 19:26
(Received via mailing list)
Issue #6867 has been updated by nagachika (Tomoyuki Chikanaga).


Hi,

This issue seems happen after r36640.
----------------------------------------
Bug #6867: super in a Mutex#synchronize block
https://bugs.ruby-lang.org/issues/6867#change-28870

Author: Eregon (Benoit Daloze)
Status: Open
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-08-14 trunk 36700) [x86_64-darwin10.8.0]


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 `<main>'

I met the bug with the listen gem: 
https://github.com/guard/listen/blob/master/lib/li... 
.
Posted by tenderlovemaking (Aaron Patterson) (Guest)
on 2012-08-20 19:42
(Received via mailing list)
Issue #6867 has been updated by tenderlovemaking (Aaron Patterson).

File fix.patch added

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.
----------------------------------------
Bug #6867: super in a Mutex#synchronize block
https://bugs.ruby-lang.org/issues/6867#change-28945

Author: Eregon (Benoit Daloze)
Status: Open
Priority: Normal
Assignee: shugo (Shugo Maeda)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-08-14 trunk 36700) [x86_64-darwin10.8.0]


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 `<main>'

I met the bug with the listen gem: 
https://github.com/guard/listen/blob/master/lib/li... 
.
Posted by shugo (Shugo Maeda) (Guest)
on 2012-08-27 14:01
(Received via mailing list)
Issue #6867 has been updated by shugo (Shugo Maeda).

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?

----------------------------------------
Bug #6867: super in a Mutex#synchronize block
https://bugs.ruby-lang.org/issues/6867#change-28966

Author: Eregon (Benoit Daloze)
Status: Assigned
Priority: Normal
Assignee: tenderlovemaking (Aaron Patterson)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-08-14 trunk 36700) [x86_64-darwin10.8.0]


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 `<main>'

I met the bug with the listen gem: 
https://github.com/guard/listen/blob/master/lib/li... 
.
Posted by mulberry (mulberry outlet) (Guest)
on 2012-09-13 08:06
(Received via mailing list)
Issue #6867 has been updated by mulberry (mulberry outlet).


"Isabel Marant":http://www.isabelmarant-bottes.com
<a href="http://www.isabelmarant-bottes.com">Isabel Marant</a>

----------------------------------------
Bug #6867: super in a Mutex#synchronize block
https://bugs.ruby-lang.org/issues/6867#change-29274

Author: Eregon (Benoit Daloze)
Status: Assigned
Priority: Normal
Assignee: tenderlovemaking (Aaron Patterson)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-08-14 trunk 36700) [x86_64-darwin10.8.0]


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 `<main>'

I met the bug with the listen gem: 
https://github.com/guard/listen/blob/master/lib/li... 
.
Posted by mame (Yusuke Endoh) (Guest)
on 2013-02-18 14:01
(Received via mailing list)
Issue #6867 has been updated by mame (Yusuke Endoh).

Status changed from Assigned to Closed

The patch was applied at r36784.

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Bug #6867: super in a Mutex#synchronize block
https://bugs.ruby-lang.org/issues/6867#change-36527

Author: Eregon (Benoit Daloze)
Status: Closed
Priority: Normal
Assignee: tenderlovemaking (Aaron Patterson)
Category: core
Target version: 2.0.0
ruby -v: ruby 2.0.0dev (2012-08-14 trunk 36700) [x86_64-darwin10.8.0]


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 `<main>'

I met the bug with the listen gem: 
https://github.com/guard/listen/blob/master/lib/li... 
.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.