Debugging optimisation unstable code - Stack and other tools

I am working to get the bugs out of Phoenix and have a situation where some tests are optimisation unstable - they run on Clang 3.5 with -O1 but not -O2 and on gcc 4.9.0 with -O0 but not -O1. The higher optimisation gives an erroneous return value. I am looking for tools to work with this. I have found one called Stack (http://css.csail.mit.edu/stack/). I have built it but it only has instructions for whole projects rather than individual tests. It is hard to search for because the word 'stack' has lots of other meanings. Has anyone else used this or any other tools to solve this sort of problem? It is worth noting that some of the tests run fine on develop testing. That leads me to wonder if the level of optimisation used there is documented anywhere. Thanks John

On 22/01/2015 15:35, Fletcher, John P wrote:
I am working to get the bugs out of Phoenix and have a situation where some tests are optimisation unstable - they run on Clang 3.5 with -O1 but not -O2 and on gcc 4.9.0 with -O0 but not -O1. The higher optimisation gives an erroneous return value.
I am looking for tools to work with this.
You can enable the sanitizers bundled with clang and gcc. You can also try valgrind.

________________________________________ From: Boost [boost-bounces@lists.boost.org] on behalf of Mathias Gaunard [mathias.gaunard@ens-lyon.org] Sent: 22 January 2015 15:59 To: boost@lists.boost.org Subject: Re: [boost] Debugging optimisation unstable code - Stack and other tools On 22/01/2015 15:35, Fletcher, John P wrote:
I am working to get the bugs out of Phoenix and have a situation where some tests are optimisation unstable - they run on Clang 3.5 with -O1 but not -O2 and on gcc 4.9.0 with -O0 but not -O1. The higher optimisation gives an erroneous return value.
I am looking for tools to work with this.
You can enable the sanitizers bundled with clang and gcc. You can also try valgrind.
Thank you. I have been trying the sanitizers (clang version) without success. None report anything and using -fsanitize=undefined caused the error to disappear! I want to try making finer grained optimization but have not succeeded yet. John

On 22 Jan 2015 at 16:17, Fletcher, John P wrote:
I am working to get the bugs out of Phoenix and have a situation where some tests are optimisation unstable - they run on Clang 3.5 with -O1 but not -O2 and on gcc 4.9.0 with -O0 but not -O1. The higher optimisation gives an erroneous return value.
I am looking for tools to work with this.
I want to try making finer grained optimization but have not succeeded yet.
I assume you've tried turning off aliasing optimisation but otherwise with optimisation on? Weird failures with O2 not seen on O1 are usually aliasing bugs in my experience. Niall -- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/

On 22/01/2015 17:17, Fletcher, John P wrote:
________________________________________ From: Boost [boost-bounces@lists.boost.org] on behalf of Mathias Gaunard [mathias.gaunard@ens-lyon.org] Sent: 22 January 2015 15:59 To: boost@lists.boost.org Subject: Re: [boost] Debugging optimisation unstable code - Stack and other tools
On 22/01/2015 15:35, Fletcher, John P wrote:
I am working to get the bugs out of Phoenix and have a situation where some tests are optimisation unstable - they run on Clang 3.5 with -O1 but not -O2 and on gcc 4.9.0 with -O0 but not -O1. The higher optimisation gives an erroneous return value.
I am looking for tools to work with this.
You can enable the sanitizers bundled with clang and gcc. You can also try valgrind.
Thank you.
I have been trying the sanitizers (clang version) without success. None report anything and using -fsanitize=undefined caused the error to disappear!
-fsanitize=undefined is pretty basic, you can try enabling the more advanced sanitizers, like address or memory.
I want to try making finer grained optimization but have not succeeded yet.
You can try to isolate what optimization pass is causing the problem by looking at the difference between the different optimization levels and trying individual flags.

22.01.2015 17:35, Fletcher, John P пишет: > Has anyone else used this or any other tools to solve this sort of problem? I'd try to do the following: 1. Create two executables, optimized and not optimized. 2. Execute them in parallel using my favourite debugger. 3. Look for any differences. 4. Find the line of code that behaves differently. 5. Look at the code generated and try to understand it. -- Best regards, Sergey Cheban
participants (4)
-
Fletcher, John P
-
Mathias Gaunard
-
Niall Douglas
-
Sergey Cheban