Monks,

I have a strange bug and I don’t know how to track it down…Hopefully I am missing something simple *cough* - so please, feel free to ridicule me:)

I have a large XS module that has an extensive test suite. The module itself processed lots of numeric data (double) with the data and the results passed between Perl and C via the XS layer. The module is for Win32 and Linux.

One of the tests when run under Linux has been failing for a long time. I have always thought that this failure was a simple rounding issue, and as such wasn’t important (my first mistake!). As more functionality and tests have been added to the module, more of the tests are starting to fail under Linux. All these failures are slight variations in the expected results on numeric values (such as 6.542 rather that 6.5). When the module is built with no optimization (-O0) on Linux, the error goes away. When any other optimization are used (1 through 3), it always fails.

To confuse things further, regardless of the optimization level when the failing tests run under valgrind the test pass (with no valgrind warning/error).

The same test suite always works under windows (mingw 3.6.x and 4.x) regardless of the optimization level. I have tried several Linux distros, different versions of Perl (5.8.x), and different versions of GCC (3.x and 4.x) and played with the fast math flags, but the results are always the same: Any optimization flag other than –O0 the test suite fails (but always works when run under valgrind!). As this error is becoming more common, I really need to understand what is causing it and ideally fix the underlying problem (which is likely to be my code).

I am at a loss at how to track it down and am not sure what to try next? As the module is large, and the datasets even larger, I don’t really want to step through a debugger or add lots of print statements – but that is all I can think of?


In reply to XS optimization bug? by Anonymous Monk

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.