Sometimes you end up in a state where you can’t catch your crash in
any of the methods in [debugging].
In this case you can tell ruby to generate a core dump. I have no idea where this stuff is documented.
First set the max size of all core files (?) to be unlimited:
ulimit -c unlimited
Then (on OSX, don’t know about Linux), make sure that the
exists and is writable by your user. There are more elegant ways of doing this
but I did
sudo mkdir /cores sudo chown -R mattvh /cores
Now replicate your crash using
make run or
make runruby or running your test
or whatever. Once it crashes you’ll see that there is a file inside
called something like
You can load this into
lldb ./ruby -c /cores/core.12387
and now you’ve got a post-mortem debugger that allows you to walk the stack just like you were live debugging a process.
NOTE: You’re going to want to clean these out regularly. each core file is large (the ones I generated from running a single test are >2GiB)