2009/8/22 Thomas Adam <[email protected]>:
> 2009/8/22 Dominik Vogt <[email protected]>:
>> On Sat, Aug 22, 2009 at 10:58:23AM -0500, fvwm-workers wrote:
>>> CVSROOT:      /home/cvs/fvwm
>>> Module name:  fvwm
>>> Changes by:   tadam   09/08/22 10:58:23
>>>
>>> Modified files:
>>>       .              : ChangeLog
>>>       fvwm           : geometry.c
>>>
>>> Log message:
>>> Fix gcc -O3 bug when resizing aspect-ratio windows.
>>>
>>> Due to how the calculations are done in
>>> geometry.c:__cs_handle_aspect_ratio(), the compiler optimizes the out
>>> completely -- make the local variables to that function volatile to stop an
>>> infinite loop in FVWM when resizing a window with aspect ratio, such as
>>> Mplayer.
>>
>> Which version of gcc is that?  I had some trouble with gcc
>> optimization recently in another project.  There's probably an
>> option to disable the offending optimization.
>
> It's the following:
>
> [n6ta...@shuttle][~]% gcc-4.3 --version
> gcc-4.3 (Debian 4.3.4-1) 4.3.4

I suppose that in this case with FVWM it was -O3 providing:

-fpredictive-commoning

Under GDB I tracked this down to geometry.c:700:

r = (double)s.width / (double)s.height;

The do..while loop there, must be causing r and other variables there
in to retain their values effectively -- where the compiler just
doesn't assume they need updating quick enough -- that's where
volatile comes in to tell the compiler that they *do* in fact change.

I wouldn't be surprised if the other sporadic -O3 fixes that have gone
into FVWM were as a result of -fpredictive-commoning, although I
haven't done much regression testing on disabling this to really find
out.

Another interesting observation on tracking this down was I tried to
only declare those variables I could track down in GDB as worthy of
volatile -- whilst this was initially successful, I had all manner of
odd side-effects in doing so -- especially with the aspect-ratio
calculations when resizing mplayer, so if anyone thinks there's too
many 'volatile' declarations there -- believe me -- there isn't.  :)

Depending on what your problem is Dominik, have you looked at
disabling -fpredictive-commoning?

-- Thomas Adam

Reply via email to