I’m not really sure where to start with this, but I experience a lot of
segfaults with ruby, in particular with respect to at_exit functions.
Here’s a simplified version of a function which often segfaults:
def self.stager_start deploy_mode, deploy_role, deploy_mock
# do some work here, including creating a lock in the database
at_exit do
# clear the lock
unless deploy_mock
# the next line segfaults
if deploy_mode != :unstaged
# this line is not reached
end
# nor is this one
end
end
end
It crashes fairly randomly and I don’t think I am going to be able to
produce a small test script to reproduce this error. I’m wondering what
my other options are.
I’m happy to try and do some debugging myself and am a capable
programmer but haven’t done much work on Ruby before so was looking for
somewhere to start.
I have tried running valgrind and get a /lot/ of errors. I have run it
through several times now without seeing a segfault but I am under the
impression that anything valgrind lists is likely to be a bug anyway and
possibly related to the problems I’m having so I will include some of
its output here:
I’m happy to try and do some debugging myself and am a capable
programmer but haven’t done much work on Ruby before so was looking for
somewhere to start.
Can you reproduce it without libxml-ruby and zmq? It’s possible that
one of these C extensions is corrupting your process and causing the
crash. By reproducing the crash without these C extensions you can be
sure that it is a ruby bug.
libxml-ruby is often accused of leaking memory and causing crashes such
as these. Do the crashes disappear if you switch to nokogiri?
A crash while looking up a method is more likely to be due to memory
corruption by a C extension than a bug in ruby.
I have tried running valgrind and get a /lot/ of errors. I have run it
through several times now without seeing a segfault but I am under the
impression that anything valgrind lists is likely to be a bug anyway and
possibly related to the problems I’m having so I will include some of
its output here:
This is not necessarily a valid assumption. One of the reports may be
valid, but there’s a lot of noise in a valgrind report without running
it with the proper configuration for ruby.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.