Last active
September 28, 2017 17:50
-
-
Save mbj/31163a8e712573877268 to your computer and use it in GitHub Desktop.
segfault.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo | |
include Enumerable | |
def each(&block) | |
[].__send__(:each, &block) | |
rescue Exception | |
end | |
def more | |
to_a # any method from enumerable | |
[self] | |
end | |
end | |
def call(resource) | |
resource.more.each(&method(__method__)) | |
end | |
Thread.new do | |
Kernel.catch(Exception.new) do | |
call(Foo.new) | |
end | |
end.join | |
# It is expected to: | |
# a) Raise a system stack error (expected) | |
# b) Segfault (Bug in MRI I'm hunting) | |
# c) Hang (Serve bug in MRI I'm hunting) please also check via strace / gdb if a segfault happened and the signal handler is trapped in a futex | |
# Context: https://github.com/mbj/mutant/issues/265 |
2.2.3 and 2.2.2 give me the same results.
ruby segfault.rb
segfault.rb:10:in `to_a': stack level too deep (SystemStackError)
from segfault.rb:10:in `more'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
... 1189 levels...
from segfault.rb:16:in `call'
from segfault.rb:21:in `block (2 levels) in <main>'
from segfault.rb:20:in `catch'
from segfault.rb:20:in `block in <main>'
ruby --version
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
of note, 2.3dev just hangs for me.
[mathieu@hz550 loyalty]$ rvm use 2.2.8
Using /home/mathieu/.rvm/gems/ruby-2.2.8
[mathieu@hz550 loyalty]$ ruby segfault.rb
segfault.rb:10:in `to_a': stack level too deep (SystemStackError)
from segfault.rb:10:in `more'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
... 1103 levels...
from segfault.rb:16:in `call'
from segfault.rb:21:in `block (2 levels) in <main>'
from segfault.rb:20:in `catch'
from segfault.rb:20:in `block in <main>'
[mathieu@hz550 loyalty]$ ruby -v
ruby 2.2.8p477 (2017-09-14 revision 59906) [x86_64-linux]
[mathieu@hz550 loyalty]$ rvm use 2.3.5
Using /home/mathieu/.rvm/gems/ruby-2.3.5
[mathieu@hz550 loyalty]$ ruby segfault.rb
segfault.rb:10:in `to_a': stack level too deep (SystemStackError)
from segfault.rb:10:in `more'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
from segfault.rb:16:in `each'
from segfault.rb:16:in `call'
... 809 levels...
from segfault.rb:16:in `call'
from segfault.rb:21:in `block (2 levels) in <main>'
from segfault.rb:20:in `catch'
from segfault.rb:20:in `block in <main>'
[mathieu@hz550 loyalty]$ rvm use 2.4.2
Using /home/mathieu/.rvm/gems/ruby-2.4.2
[mathieu@hz550 loyalty]$ ruby segfault.rb
segfault.rb:10: [BUG] vm_call_cfunc - cfp consistency error
ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
-- Control frame information -----------------------------------------------
Segmentation fault (core dumped)
[mathieu@hz550 loyalty]$
ArchLinux 64bit
Linux hz550 4.12.12-1-ARCH #1 SMP PREEMPT Sun Sep 10 09:41:14 CEST 2017 x86_64 GNU/Linux
on debian 14.04 I am getting segfault.rb:10: [BUG] vm_call_cfunc - cfp consistency error
on 2.2.8
mathieu@ubuntu-1404 (i-123):~$ ruby segfault.rb
Segmentation fault (core dumped)
mathieu@ubuntu-1404 (i-123):~$
with brighbox compiled packages
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This problem was probably solved with: ruby/ruby@8fe95fe