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

Ralf Corsepius rc040203 at freenet.de
Sat Nov 19 13:08:08 UTC 2011


On 11/19/2011 01:23 PM, Andrew Haley wrote:
> On 11/18/2011 11:32 PM, Tom Lane wrote:
>> Andrew Haley<aph at redhat.com>  writes:
>>>> On 11/18/2011 05:53 PM, Ralf Corsepius wrote:
>>>>>> pptp.c:459:33: warning: dereferencing type-punned pointer might break
>>>>>> strict-aliasing rules [-Wstrict-aliasing]
>>>> Bingo!  Bugs like this must be fixed.
>> Sometimes that's easier said than done.  -fno-strict-aliasing might be
>> your friend.
>
> It's always easier said than done!  Still, one could argue
> that -fno-strict-aliasing is a fix, kinda sorta.
It's a work-around to evaluate whether aliasing actucally is the cause 
of this BZ.

> My point is
> that you've got to do *something*; this warning must not be
> ignored.

The code in question is a classic of the GCC-aliasing cases:
sockaddr vs. sockaddr_{in,un,..} casts.

The standard work-around to the GCC warnings would be using unions, 
containing fields of these types. Whether these spots actually are 
affected by aliasing issues, is a different matter.

[I have seen cases of this sort, where aliasing actually had malicious 
effects, but I've also seen cases it didn't.]

Ralf


More information about the devel mailing list