If changes to comments affect the bug, then that is strongly suggestive that the problem is due to C-level code writing somewhere random that it shouldn't. That could be a bug in Perl. That could be a bug in C code in the XS library. Unfortunately for you, any change in how Perl lays out its data will move the bug around (and if the data overwritten is purely informational, you won't see it - until the program changes again).

There are tools (eg purify) which attempt to detect and locate this kind of bug in an automated way. The tools are far from perfect, but they are better than nothing. I would strongly recommend getting someone who is knowledgeable about how to use them to study the XS modules to see if any bugs of this kind can be located and fixed. (I suggest focussing on XS modules because perl is more complex, and people have looked for this kind of problem in it so it is less likely to have this kind of bug than random libraries. Plus studying the modules with these tools will likely find several other bugs that you'll be glad to fix.)

If the automated solution fails, you could try a manual audit of the XS code. That is a little hit or miss because where the bug shows up is not going to be anywhere near where the bug is. If you can figure out what address is getting corrupted (sorry, I don't have good ideas for how you would do this except by staring at the stack backtrace, guessing and being lucky), you might be able to trace the running program and try to figure out when it gets messed up. This could simplify the audit.

Good luck. Incidentally the difficulty of attempting to track this kind of bug down is a very good argument against using C except when you absolutely have to. Alternately if you do use C, it is a good argument for using all of the techniques that you can to track down this kind of bug.


In reply to Re^3: Techniques for isolating bugs in perl by tilly
in thread Techniques for isolating bugs in perl by Ytrew

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.