I’ve got a C++ application that initializes a Ruby interpreter and opens
itself up to scripting via SWIG. Everything is working fine, but I seem
to be getting segfaults on internal garbage collection. That is, if I
call GC.start myself, there isn’t a problem, but when it gets called by
the interpreter (via ALLOC_N?), there’s a crash.
At least, this is my guess – I only have a release version of the
library right now, so all my debugger can show me is assembly code. It
looks like the problem is happening around rb_gc_finalize_deferred and
the stack_check call. If I disable garbage collection in script, the
crash never happens.
I’m fairly sure the problem is caused by something stupid that I’m
doing, but because I only have the binary, I can’t figure out what it
might be. I looked at the distribution Makefile, but couldn’t see any
flags to enable debug symbols. I was wondering if anybody had any
pointers on building the interpreter in debug mode, preferably an OS X
dylib.
(If anybody has any more direct thoughts on what might be causing the
issue, I would, of course, appreciate those as well. :-))