Hi fellow monks,

I'm using Inline::pdlpp to write some C routines, embedded in my Perl code.

My problem: I'm getting a segfault that I can't track down. I've looked through my code with particular attention to what the pointers are doing, and it looks ok. But of course it might not be. Pdlpp generates quite a bit of C that wraps round my functions, the problem could be there, too.

My question: how best to track down this segfault?

It's been a few years (like, about 15 years) since I did any C programming, but I've been doing some revision and it seems like the standard technique is to load the core file into gdb (the debugger) and go from there, or to run it under something like Valgrind which will tell me where I'm going wrong.

But: I don't know how to do those things, given that the code is itself embedded in a Perl script. Right now I'm not even getting a core file that I could load into gdb.

So, any suggestions greatly appreciated. As you can probably tell I'm fairly new to this area so apologies if I'm missing something obvious...

I'm using Mac OS X on Intel BTW, if that makes a difference to choice of tools.

Best wishes, andye

Update: I've read this node: Debugging Inline C programs but I'm still some way from being enlightened... I need to recompile perl itself with '-g'? Sounds like a pain... Currently I'm passing Config => OPTIMIZE => '-g' to Inline::Pldpp, but I'm not sure what my next step is meant to be...


In reply to Debugging segfault in inline C (actually inline pdlpp, but probably the same principle) by andye

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.