[compiz] possible division by zero in screen.c

David Reveman davidr at novell.com
Wed Apr 4 06:20:19 PDT 2007

On Mon, 2007-04-02 at 12:41 +0100, Nicholas Thomas wrote:
> Hi,
> In detectRefreshRateOfScreen(), we have
> s->redrawTime = 1000 / s->opt[COMP_SCREEN_OPTION_REFRESH_RATE].value.i;
> When the refresh rate is autodetected through RandR's XRRConfigCurrentRate 
> function, 0 can be returned in certain cases, leading to division by zero. An 
> example of this situation would be the DynamicTwinView option in the nVidia 
> proprietary drivers[0] (note that this is the default option in TwinView 
> configurations). Apparently, it can happen in other situations as well.
> A simple patch that falls back to the manually-set refresh rate when a SIGFPE 
> is imminent is attached, but I don't think it's really the best way to deal 
> with this situation. In particular, where the index doesn't = 0, there'll be 
> no crash but the refresh rate will be stupidly slow. A better solution might 
> be to fall back to the manual setting where a stupid (e.g.  < 50 ?) refresh 
> rate has been autodetected.
> Technically, it's the driver behaving in a broken way, but it'd be nice to 
> avoid the crash.

Sure, we should avoid the crash.

I think

+    if (value.i == 0)
+        value.i = defaultRefreshRate;

is a bit more appropriate.

- David

More information about the compiz mailing list