Skip to content

Instantly share code, notes, and snippets.

@mbj
Last active September 28, 2017 17:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbj/31163a8e712573877268 to your computer and use it in GitHub Desktop.
Save mbj/31163a8e712573877268 to your computer and use it in GitHub Desktop.
segfault.rb
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
@mathieujobin
Copy link

mathieujobin commented Sep 28, 2017

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