[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nmh-workers] mhstore dumps core

From: Ralph Corderoy
Subject: Re: [Nmh-workers] mhstore dumps core
Date: Sat, 19 Aug 2017 14:41:06 +0100

Hi David,

> > valgrind here, 3.13.0-2, doesn't complain about the printf, and that
> > prints zero.  That puzzles me.
> Yes, interesting.  Have you tried with -O0?

gcc 7.1.1-4.  valgrind 3.13.0-2.

        -O0  Compile fails;  optimisation needed.
        -O2  valgrind finds the problem.
        -O3  valgrind doesn't complain.  My default.

    Without -D_FORTIFY_SOURCE=2:
        -O0  valgrind finds the problem.
        -O2  valgrind finds the problem.
        -O3  gcc finds the problem, valgrind doesn't.

So valgrind looks best with -O2, but gcc spots some problems itself at
-O3 if no -D_FORTIFY_SOURCE=2.


    If you are planning to use Memcheck: On rare occasions, compiler
    optimisations (at -O2 and above, and sometimes -O1) have been
    observed to generate code which fools Memcheck into wrongly
    reporting uninitialised value errors, or missing uninitialised value
    errors.  We have looked in detail into fixing this, and
    unfortunately the result is that doing so would give a further
    significant slowdown in what is already a slow tool.  So the best
    solution is to turn off optimisation altogether.  Since this often
    makes things unmanageably slow, a reasonable compromise is to use
    -O.  This gets you the majority of the benefits of higher
    optimisation levels whilst keeping relatively small the chances of
    false positives or false negatives from Memcheck.

> I'm ambivalent about OK and NOTOK.  Sometimes they provide more
> readable code, I think, but not always.

Yes, I expect they're right some of the time.  :-)

Cheers, Ralph.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]