Does anyone have some general tips for debugging segmentation faults that they'd like to share? Most of the time, perl -d is sufficient for debugging, but here, since the debugger and debuggee are in the same process, that segmentation fault kinda brings both down at the same time.

And my manager is kinda finicky that we don't check in anything that causes a segmentation fault :-)

I'm trying to narrow it down, but as I said, I can usually use perl -d, so I can much more easily get stack traces at warnings and the like, so I don't have nearly the experience at dealing with these as I'd like. I'm sure I'm doing something wrong, but I must be doing it wrong in such a way that the perl virtual machine gets really confused...

Update: And it doesn't help that the program hangs on filesystem calls every once in a while... (e.g., we have a driver that runs over NFS which has proved less than perfectly reliable on Linux where I'm testing this... as if NFS wasn't unreliable enough...)

Update 2: I should have said so at the beginning, but Anonymonk is reminding me so I'll say that I've had similar experiences moving from perl 5.6.1 to perl 5.8.0 solving a number of problems I had integrating XML::Twig into this same project (that requirement then went away). So I'm now testing/developing/going into production with perl 5.8.6. It took us nearly a year to get them to upgrade to 5.8.6, I'm not going to be able to convince them to move up again for at least another year, possibly two. However, I'm pretty convinced that I should be able to work around this segfault as this section of code was working just two weeks ago (last time I tested it), so I must have done something to twist perl's understanding of what to do.

Further, to hv's comment, I don't get core. I'm running as root. And my code won't work without root privileges. :-) But compiling a debugging perl may be an option. Thanks.


In reply to Debugging tips for segmentation faults? by Tanktalus

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.