Garbage Collection segfault and debug interpreter

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. :-))

Hi,

At Wed, 12 Sep 2007 12:20:16 +0900,
Shane Liesegang wrote in [ruby-talk:268727]:

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.

configure --cflags=‘debug options’

perhaps if you gave us some more information about what you are doing,
esp. source code, then someone may be able to help.

Tom