Bug #9315
closedSegfault when calling super in rspec mocks with and_call_original [linux]
Added by jgraichen (Jan Graichen) almost 11 years ago. Updated almost 11 years ago.
Description
I've tried running my test suite [1] on Ruby 2.1 resulting in segmentation faults. I've created a smaller rspec test [2] reproducing the segfault. I still haven't found a way to reproduce the segfault without rspec mocks. Run the example via rspec test.rb
. Same script on Ruby 2.0 works. Used linux is a Debian Sid.
[1] https://travis-ci.org/jgraichen/acfs/jobs/16069122#L87
[2] https://gist.github.com/jgraichen/8159849
I've attached the segfault output.
Files
Updated by mame (Yusuke Endoh) almost 11 years ago
- Status changed from Open to Assigned
- Assignee set to nobu (Nobuyoshi Nakada)
Good catch. Here is a smaller example:
module A
def foo
super
end
end
class B
include A
end
B.new.method(:foo).call
I think r44179 caused this issue.
--
Yusuke Endoh mame@tsg.ne.jp
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
This issue was solved with changeset r44455.
Jan, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
vm_insnhelper.c: missing super in method module
- vm_insnhelper.c (
vm_search_super_method
): direct superclass of a
module is found when super called in a Method object generated a
method defined in a module, callmethod_missing
in that case.
[ruby-core:59358] [Bug #9315]
Updated by nagachika (Tomoyuki Chikanaga) almost 11 years ago
Hello,
r44175 and r44179 were already backported to ruby_2_0_0 branch at r44345.
But I cannot reproduce SEGV on 2.0.0-head(r44393) with testcase in r44455.
I wonder if I should backport r44458 to ruby_2_0_0. Any idea?
Updated by jgraichen (Jan Graichen) almost 11 years ago
I've finally had time to test my test suite on current ruby heads and encountered some other similar problems again.
Given the following example:
module Persistence
def save!
# save to disk etc.
puts "saved!"
end
end
module Validation
def valid?(context)
true
end
# Hook save!
def save!(*args)
return false unless valid? :create
super
end
end
class Model
include Persistence
include Validation
end
Model.new.method(:save!).call
On ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-linux]
:
> ruby test.rb
saved!
On ruby 2.0.0p377 (2014-01-03 revision 44491) [x86_64-linux]
:
> ruby test.rb
test.rb:16:in `save!': super: no superclass method `save!' for #<Model:0x00000000dccc88> (NoMethodError)
from test.rb:25:in `call'
from test.rb:25:in `<main>'
And on ruby 2.1.1p2 (2013-12-31 revision 44467) [x86_64-linux]
:
> ruby test.rb
test.rb:16: [BUG] Segmentation fault at 0x00000000000018
ruby 2.1.1p2 (2013-12-31 revision 44467) [x86_64-linux]
-- Control frame information -----------------------------------------------
c:0004 p:0026 s:0012 e:000010 METHOD test.rb:16 [FINISH]
c:0003 p:---- s:0007 e:000006 CFUNC :call
c:0002 p:0047 s:0004 E:001ca8 EVAL test.rb:25 [FINISH]
c:0001 p:0000 s:0002 E:001978 TOP [FINISH]
-- Ruby level backtrace information ----------------------------------------
test.rb:25:in `<main>'
test.rb:25:in `call'
test.rb:16:in `save!'
-- C level backtrace information -------------------------------------------
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1e18ec) [0x7f40e25dd8ec] vm_dump.c:685
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x76d43) [0x7f40e2472d43] error.c:307
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(rb_bug+0xb3) [0x7f40e2473993] error.c:334
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1595ce) [0x7f40e25555ce] signal.c:704
/lib/x86_64-linux-gnu/libpthread.so.0(+0xf210) [0x7f40e21ef210]
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1cba03) [0x7f40e25c7a03] vm_method.c:573
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1cfe79) [0x7f40e25cbe79] vm_insnhelper.c:2029
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1d393c) [0x7f40e25cf93c] vm.c:1304
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1d47f4) [0x7f40e25d07f4] vm_eval.c:171
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1d5477) [0x7f40e25d1477] vm_eval.c:50
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(rb_method_call_with_block+0x10a) [0x7f40e248456a] proc.c:1833
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1d7e41) [0x7f40e25d3e41] vm_insnhelper.c:1470
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1cfd54) [0x7f40e25cbd54] insns.def:1028
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x1d393c) [0x7f40e25cf93c] vm.c:1304
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(rb_iseq_eval_main+0x1f6) [0x7f40e25d8986] vm.c:1562
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(+0x7ceea) [0x7f40e2478eea] eval.c:253
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(ruby_exec_node+0x1d) [0x7f40e247ae7d] eval.c:318
/home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1(ruby_run_node+0x1c) [0x7f40e247d2bc] eval.c:310
ruby() [0x40088b]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf5) [0x7f40e171c995]
ruby() [0x4008b9]
-- Other runtime information -----------------------------------------------
* Loaded script: test.rb
* Loaded features:
0 enumerator.so
1 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/encdb.so
2 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/trans/transdb.so
3 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/rbconfig.rb
4 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/compatibility.rb
5 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/defaults.rb
6 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/deprecate.rb
7 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/errors.rb
8 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/version.rb
9 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/requirement.rb
10 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/platform.rb
11 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/basic_specification.rb
12 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/stub_specification.rb
13 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/util/stringio.rb
14 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/specification.rb
15 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/exceptions.rb
16 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb
17 thread.rb
18 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/thread.so
19 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/monitor.rb
20 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb
21 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/site_ruby/2.1.0/rubygems.rb
* Process memory map:
00400000-00401000 r-xp 00000000 fe:03 17045008 /home/jan/.rvm/rubies/ruby-2.1.0-head/bin/ruby
00600000-00601000 rw-p 00000000 fe:03 17045008 /home/jan/.rvm/rubies/ruby-2.1.0-head/bin/ruby
019d1000-01e6a000 rw-p 00000000 00:00 0 [heap]
7f40e0be4000-7f40e0bf9000 r-xp 00000000 fe:02 1966585 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f40e0bf9000-7f40e0df9000 ---p 00015000 fe:02 1966585 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f40e0df9000-7f40e0dfa000 rw-p 00015000 fe:02 1966585 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f40e0dfa000-7f40e0dfd000 r-xp 00000000 fe:03 17045821 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/thread.so
7f40e0dfd000-7f40e0ffc000 ---p 00003000 fe:03 17045821 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/thread.so
7f40e0ffc000-7f40e0ffd000 rw-p 00002000 fe:03 17045821 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/thread.so
7f40e0ffd000-7f40e0fff000 r-xp 00000000 fe:03 17045808 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/trans/transdb.so
7f40e0fff000-7f40e11ff000 ---p 00002000 fe:03 17045808 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/trans/transdb.so
7f40e11ff000-7f40e1200000 rw-p 00002000 fe:03 17045808 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/trans/transdb.so
7f40e1200000-7f40e1202000 r-xp 00000000 fe:03 17045760 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/encdb.so
7f40e1202000-7f40e1401000 ---p 00002000 fe:03 17045760 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/encdb.so
7f40e1401000-7f40e1402000 rw-p 00001000 fe:03 17045760 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/ruby/2.1.0/x86_64-linux/enc/encdb.so
7f40e1402000-7f40e16fb000 r--p 00000000 fe:02 551553 /usr/lib/locale/locale-archive
7f40e16fb000-7f40e189e000 r-xp 00000000 fe:02 1966939 /lib/x86_64-linux-gnu/libc-2.17.so
7f40e189e000-7f40e1a9d000 ---p 001a3000 fe:02 1966939 /lib/x86_64-linux-gnu/libc-2.17.so
7f40e1a9d000-7f40e1aa1000 r--p 001a2000 fe:02 1966939 /lib/x86_64-linux-gnu/libc-2.17.so
7f40e1aa1000-7f40e1aa3000 rw-p 001a6000 fe:02 1966939 /lib/x86_64-linux-gnu/libc-2.17.so
7f40e1aa3000-7f40e1aa7000 rw-p 00000000 00:00 0
7f40e1aa7000-7f40e1ba3000 r-xp 00000000 fe:02 1966949 /lib/x86_64-linux-gnu/libm-2.17.so
7f40e1ba3000-7f40e1da3000 ---p 000fc000 fe:02 1966949 /lib/x86_64-linux-gnu/libm-2.17.so
7f40e1da3000-7f40e1da4000 r--p 000fc000 fe:02 1966949 /lib/x86_64-linux-gnu/libm-2.17.so
7f40e1da4000-7f40e1da5000 rw-p 000fd000 fe:02 1966949 /lib/x86_64-linux-gnu/libm-2.17.so
7f40e1da5000-7f40e1dad000 r-xp 00000000 fe:02 1966946 /lib/x86_64-linux-gnu/libcrypt-2.17.so
7f40e1dad000-7f40e1fac000 ---p 00008000 fe:02 1966946 /lib/x86_64-linux-gnu/libcrypt-2.17.so
7f40e1fac000-7f40e1fad000 r--p 00007000 fe:02 1966946 /lib/x86_64-linux-gnu/libcrypt-2.17.so
7f40e1fad000-7f40e1fae000 rw-p 00008000 fe:02 1966946 /lib/x86_64-linux-gnu/libcrypt-2.17.so
7f40e1fae000-7f40e1fdc000 rw-p 00000000 00:00 0
7f40e1fdc000-7f40e1fdf000 r-xp 00000000 fe:02 1966937 /lib/x86_64-linux-gnu/libdl-2.17.so
7f40e1fdf000-7f40e21de000 ---p 00003000 fe:02 1966937 /lib/x86_64-linux-gnu/libdl-2.17.so
7f40e21de000-7f40e21df000 r--p 00002000 fe:02 1966937 /lib/x86_64-linux-gnu/libdl-2.17.so
7f40e21df000-7f40e21e0000 rw-p 00003000 fe:02 1966937 /lib/x86_64-linux-gnu/libdl-2.17.so
7f40e21e0000-7f40e21f7000 r-xp 00000000 fe:02 1966931 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f40e21f7000-7f40e23f6000 ---p 00017000 fe:02 1966931 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f40e23f6000-7f40e23f7000 r--p 00016000 fe:02 1966931 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f40e23f7000-7f40e23f8000 rw-p 00017000 fe:02 1966931 /lib/x86_64-linux-gnu/libpthread-2.17.so
7f40e23f8000-7f40e23fc000 rw-p 00000000 00:00 0
7f40e23fc000-7f40e26a7000 r-xp 00000000 fe:03 17045009 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1.0
7f40e26a7000-7f40e28a7000 ---p 002ab000 fe:03 17045009 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1.0
7f40e28a7000-7f40e28af000 rw-p 002ab000 fe:03 17045009 /home/jan/.rvm/rubies/ruby-2.1.0-head/lib/libruby.so.2.1.0
7f40e28af000-7f40e28d5000 rw-p 00000000 00:00 0
7f40e28d5000-7f40e28f6000 r-xp 00000000 fe:02 1966711 /lib/x86_64-linux-gnu/ld-2.17.so
7f40e29c2000-7f40e2ac8000 rw-p 00000000 00:00 0
7f40e2aef000-7f40e2af0000 rw-p 00000000 00:00 0
7f40e2af0000-7f40e2af1000 ---p 00000000 00:00 0
7f40e2af1000-7f40e2af6000 rw-p 00000000 00:00 0 [stack:26115]
7f40e2af6000-7f40e2af7000 r--p 00021000 fe:02 1966711 /lib/x86_64-linux-gnu/ld-2.17.so
7f40e2af7000-7f40e2af9000 rw-p 00022000 fe:02 1966711 /lib/x86_64-linux-gnu/ld-2.17.so
7fffd4700000-7fffd4721000 rw-p 00000000 00:00 0
7fffd47fe000-7fffd4800000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
Aborted
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
Seems working on the trunk.
Updated by jgraichen (Jan Graichen) almost 11 years ago
Yes, ruby 2.2.0dev (2014-01-06 trunk 44510) [x86_64-linux]
indeed works. Looks somehow I missed the most important head. Sorry.
At least the error on current 2.0.0-head seems interesting, should I open another bug for it?
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Backport changed from 1.9.3: UNKNOWN, 2.0.0: UNKNOWN, 2.1: UNKNOWN to 1.9.3: DONTNEED, 2.0.0: REQUIRED, 2.1.0: REQUIRED
r44458 fixed it.
Now I filled the Backport property, it will be backported.
Updated by nagachika (Tomoyuki Chikanaga) almost 11 years ago
- Backport changed from 1.9.3: DONTNEED, 2.0.0: REQUIRED, 2.1.0: REQUIRED to 1.9.3: DONTNEED, 2.0.0: DONE, 2.1.0: REQUIRED
Hello,
Jan, thank you for your investigation!
r44455, r44458 and r44510 were backported to ruby_2_0_0
branch at r44511.
Thanks again.
Updated by nobu (Nobuyoshi Nakada) almost 11 years ago
- Is duplicate of Bug #9309: Crash while running tests added