Segmentation fault for classes with multiple modules chained with super
The following program causes segmentation fault for me with the latest macruby trunk: class A def somemethod puts "A::somemethod" end end module B def somemethod super puts "B::somemethod" end end module C def somemethod super puts "C::somemethod" end end class D < A include B include C def somemethod super puts "D::somemethod" end end obj = D.new obj.somemethod Thanks to http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder I just found that modules can be chained via super like that, so I immediately went to check it out, and in MRI 1.8 it works fine. I wanted to see it in 1.9, so I checked with macruby and it caused segmentation fault. I recompiled latest macruby trunk and it's still happening. As stated in the README.rdoc I'm using llvm trunk at revision 72741. Is it llvm or macruby bug? Oddly, under gdb it just freezes, can't even see any stack trace. :-/
On Tue, Sep 1, 2009 at 1:01 AM, Alexey Borzenkov<snaury@gmail.com> wrote:
The following program causes segmentation fault for me with the latest macruby trunk:
class A def somemethod puts "A::somemethod" end end
module B def somemethod super puts "B::somemethod" end end
module C def somemethod super puts "C::somemethod" end end
class D < A include B include C def somemethod super puts "D::somemethod" end end
obj = D.new obj.somemethod
Thanks to http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder I just found that modules can be chained via super like that, so I immediately went to check it out, and in MRI 1.8 it works fine. I wanted to see it in 1.9, so I checked with macruby and it caused segmentation fault. I recompiled latest macruby trunk and it's still happening. As stated in the README.rdoc I'm using llvm trunk at revision 72741. Is it llvm or macruby bug? Oddly, under gdb it just freezes, can't even see any stack trace. :-/
Correction: if I printed before calling super I'd see that it causes infinite recursion. Seems like it shouldn't be doing that...
Hi Alexey, Looks like you found a bug in super :) Would you be willing to contribute a snippet for test_vm/dispatch.rb? This is where we keep all these weird cases to make sure we won't forget to fix them. You can run the test using $ ruby test_vm.rb --ruby=../miniruby dispatch And also 1.9 (assuming "ruby19" is in your path) $ ruby test_vm.rb --ruby=ruby19 dispatch Laurent On Aug 31, 2009, at 2:04 PM, Alexey Borzenkov wrote:
On Tue, Sep 1, 2009 at 1:01 AM, Alexey Borzenkov<snaury@gmail.com> wrote:
The following program causes segmentation fault for me with the latest macruby trunk:
class A def somemethod puts "A::somemethod" end end
module B def somemethod super puts "B::somemethod" end end
module C def somemethod super puts "C::somemethod" end end
class D < A include B include C def somemethod super puts "D::somemethod" end end
obj = D.new obj.somemethod
Thanks to http://weblog.rubyonrails.org/2009/8/31/three-reasons-love-responder I just found that modules can be chained via super like that, so I immediately went to check it out, and in MRI 1.8 it works fine. I wanted to see it in 1.9, so I checked with macruby and it caused segmentation fault. I recompiled latest macruby trunk and it's still happening. As stated in the README.rdoc I'm using llvm trunk at revision 72741. Is it llvm or macruby bug? Oddly, under gdb it just freezes, can't even see any stack trace. :-/
Correction: if I printed before calling super I'd see that it causes infinite recursion. Seems like it shouldn't be doing that... _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
On Tue, Sep 1, 2009 at 1:12 AM, Laurent Sansonetti<lsansonetti@apple.com> wrote:
Hi Alexey,
Looks like you found a bug in super :) Would you be willing to contribute a snippet for test_vm/dispatch.rb? This is where we keep all these weird cases to make sure we won't forget to fix them.
Here it is. Works on both MRI 1.8 and 1.9: diff --git a/test_vm/dispatch.rb b/test_vm/dispatch.rb index 052f5f5..dee4376 100644 --- a/test_vm/dispatch.rb +++ b/test_vm/dispatch.rb @@ -371,3 +371,11 @@ assert "42", %{ class Y < X; def foo(x); 1.times { |; x| x = 1; super; } end; end Y.new.foo(42) } + +assert "true", %{ + class X; def foo(x); x; end; end + module M1; def foo(x); super(true); end; end + module M2; def foo(x); return false if x; super; end; end + class Y < X; include M1; include M2; def foo; super(false); end; end + p Y.new.foo +}
Added in r2452, thanks! Btw: I prefer a git format-patch diff :) Eloy On 1 sep 2009, at 20:58, Alexey Borzenkov wrote:
On Tue, Sep 1, 2009 at 1:12 AM, Laurent Sansonetti<lsansonetti@apple.com
wrote: Hi Alexey,
Looks like you found a bug in super :) Would you be willing to contribute a snippet for test_vm/dispatch.rb? This is where we keep all these weird cases to make sure we won't forget to fix them.
Here it is. Works on both MRI 1.8 and 1.9:
diff --git a/test_vm/dispatch.rb b/test_vm/dispatch.rb index 052f5f5..dee4376 100644 --- a/test_vm/dispatch.rb +++ b/test_vm/dispatch.rb @@ -371,3 +371,11 @@ assert "42", %{ class Y < X; def foo(x); 1.times { |; x| x = 1; super; } end; end Y.new.foo(42) } + +assert "true", %{ + class X; def foo(x); x; end; end + module M1; def foo(x); super(true); end; end + module M2; def foo(x); return false if x; super; end; end + class Y < X; include M1; include M2; def foo; super(false); end; end + p Y.new.foo +} _______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
participants (3)
-
Alexey Borzenkov
-
Eloy Duran
-
Laurent Sansonetti