Debuggery of extensions from segfault

I wrote my first extension!

The functions work fine... except when I'm making multiple calls in a loop.
Then, it segfaults. I wrote some more code in my extension to output
equivalent c code to do the same job - even across my multiple data, and it
does fine. So I'm thinking either there's some weirdness I don't know
about, I'm accidentally clobbering some data, or there's a bug in ruby that
I stumbled across (ruby 1.8.4 (2005-12-24) [powerpc-darwin8.4.0]) - my
question is, how do I figure this out? Right now, my plan is to add
fprintf(stderr, "%s [%d]\n", __FILE__, __LINE__); to the end of every line
in my c extension and see what gets dumped... but is there an easier way?

Thanks,

~Matthew Maycock

···

--
There's no word in the English language for what you do to a dead thing to
make it stop chasing you.

I wrote my first extension!

The functions work fine... except when I'm making multiple calls in a loop.
Then, it segfaults. I wrote some more code in my extension to output
equivalent c code to do the same job - even across my multiple data, and it
does fine. So I'm thinking either there's some weirdness I don't know
about, I'm accidentally clobbering some data, or there's a bug in ruby that
I stumbled across (ruby 1.8.4 (2005-12-24) [powerpc-darwin8.4.0]) - my
question is, how do I figure this out? Right now, my plan is to add
fprintf(stderr, "%s [%d]\n", __FILE__, __LINE__); to the end of every line
in my c extension and see what gets dumped... but is there an easier way?

Thanks,

~Matthew Maycock

- write a script called 'a.rb' that uses your ext

- start ruby in gdb using

     gdb `which ruby`

- run at gdb prompt using (assuming a.rb in cwd)

     > run 'a.rb'

- when you seg fault type

     > where

hth.

-a

···

On Fri, 31 Mar 2006, Matt Maycock wrote:
--
share your knowledge. it's a way to achieve immortality.
- h.h. the 14th dali lama

and here I spent a great deal of time wrote something to add debug
statements to all my code.

ara t howard, you are wonderful.

~Matthew Maycock

···

On 3/30/06, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:

On Fri, 31 Mar 2006, Matt Maycock wrote:

> I wrote my first extension!
>
> The functions work fine... except when I'm making multiple calls in a
loop.
> Then, it segfaults. I wrote some more code in my extension to output
> equivalent c code to do the same job - even across my multiple data, and
it
> does fine. So I'm thinking either there's some weirdness I don't know
> about, I'm accidentally clobbering some data, or there's a bug in ruby
that
> I stumbled across (ruby 1.8.4 (2005-12-24) [powerpc-darwin8.4.0]) - my
> question is, how do I figure this out? Right now, my plan is to add
> fprintf(stderr, "%s [%d]\n", __FILE__, __LINE__); to the end of every
line
> in my c extension and see what gets dumped... but is there an easier
way?
>
> Thanks,
>
> ~Matthew Maycock

- write a script called 'a.rb' that uses your ext

- start ruby in gdb using

     gdb `which ruby`

- run at gdb prompt using (assuming a.rb in cwd)

     > run 'a.rb'

- when you seg fault type

     > where

hth.

-a
--
share your knowledge. it's a way to achieve immortality.
- h.h. the 14th dali lama

--
There's no word in the English language for what you do to a dead thing to
make it stop chasing you.