Package segfaults when built with -O2 but not with -O0

Gregory Maxwell gmaxwell at gmail.com
Fri Nov 18 15:36:20 UTC 2011


On Fri, Nov 18, 2011 at 6:31 AM, Paul Howarth <paul at city-fan.org> wrote:
> 2. How to determine what the actual problem is, e.g. a problem with the
> way the code is written leading to unsafe optimizations, or a gcc bug?

[Obviously Andrew's look at warnings advice is good but also…]

See if you can reproduce it when compiled with -O2 -fno-strict-aliasing
if not, then the package violates C rules for pointer aliasing and
-Wstrict-aliasing=n can help you find the bug.

Otherwise, reproduce the crash while running in valgrind and it's pretty
likely that you'll see the cause there. (e.g. some use-uninitilized which
turns out to be harmless in O0)

Between these two that covers a pretty significant portion of bugs that
vanish at O0.


More information about the devel mailing list