https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64247

            Bug ID: 64247
           Summary: program result depends on environment ?
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: Joost.VandeVondele at mat dot ethz.ch

This is a bit an odd bug report, as it so far is just a somewhat worrying
observation:

If I run our simulation package, the output appears to change if we pipe (|) an
output to file via tee or if we direct the output (>) to file. This can be
reproduced with setting the flag GFORTRAN_UNBUFFERED_ALL as in :

> GFORTRAN_UNBUFFERED_ALL=0  ../../../exe/local/cp2k.sopt O_KG.inp 
POWELL| Number of function evaluations 3658

or

> GFORTRAN_UNBUFFERED_ALL=1  ../../../exe/local/cp2k.sopt O_KG.inp 
 POWELL| Number of function evaluations   10000

once the code converges (3658), once not.

If I run the same code under valgrind, I get no warnings/errors, but the
iteration count changes again to the old value.

 GFORTRAN_UNBUFFERED_ALL=1  valgrind ../../../exe/local/cp2k.sopt O_KG.inp 
 POWELL| Number of function evaluations   3658
[..]
==453== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 5 from 5)

This is all pretty reproducible on that particular machine. Only with gcc
4.9.2, not with earlier versions. In fact, if I pick up the old fortran runtime
libs (4.8.X) (but same cp2k binary) the problem seems to disappear.

However, I believe that this odd behavior with GFORTRAN_UNBUFFERED_ALL is maybe
coincidental. Indeed, our nightly tester can change value 'randomly' and it
looks like the result depends on the environment, in a surprising way.

Any suggestions ? 

The only wild guess I have so far is that, maybe, code flow is influenced by
the alignment of buffers returned by malloc, but I won't know how to prove that
?

Reply via email to