Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
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?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: XS optimization bug?
by BrowserUk (Patriarch) on Apr 09, 2009 at 15:17 UTC | |
by Anonymous Monk on Apr 11, 2009 at 12:39 UTC | |
|
Re: XS optimization bug?
by roboticus (Chancellor) on Apr 10, 2009 at 13:08 UTC | |
by syphilis (Archbishop) on Apr 10, 2009 at 13:37 UTC |