# Garbage Collection segfault and debug interpreter

**URL:** <https://www.ruby-forum.com/t/garbage-collection-segfault-and-debug-interpreter/114390>\
**Category:** Ruby\
**Created:** [September 12, 2007, 5:20am UTC](https://www.ruby-forum.com/t/garbage-collection-segfault-and-debug-interpreter/114390 "2007-09-12T05:20:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sjml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b19c9b/32.png) [@sjml](https://www.ruby-forum.com/u/sjml)\
**Post date:** [September 12, 2007, 5:20am UTC](https://www.ruby-forum.com/t/garbage-collection-segfault-and-debug-interpreter/114390/1 "2007-09-12T05:20:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sjml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b19c9b/32.png) [@sjml](https://www.ruby-forum.com/u/sjml)\
**Post date:** [September 12, 2007, 6:54am UTC](https://www.ruby-forum.com/t/garbage-collection-segfault-and-debug-interpreter/114390/2 "2007-09-12T06:54:08Z")

</div>

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’

---

<div class="post-metadata">

**Author:** ![sjml](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b19c9b/32.png) [@sjml](https://www.ruby-forum.com/u/sjml)\
**Post date:** [September 17, 2007, 1:24pm UTC](https://www.ruby-forum.com/t/garbage-collection-segfault-and-debug-interpreter/114390/3 "2007-09-17T13:24:00Z")

</div>

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

Tom
