xserver: Branch 'master'

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 12 14:30:48 UTC 2019


 dix/events.c |    2 ++
 1 file changed, 2 insertions(+)

New commits:
commit 61aa40aeb3d4efefda47f245ed4b83a1a19b1d4c
Author: Matt Turner <mattst88 at gmail.com>
Date:   Fri Aug 9 20:22:29 2019 -0700

    dix: Assert noPanoramiXExtension is false in PanoramiX code
    
    When compiling with link time optimization, GCC thinks it's discovered
    undefined behavior:
    
    events.c: In function 'XineramaConfineCursorToWindow':
    events.c:609:13: warning: iteration 2147483647 invokes undefined behavior [-Waggressive-loop-optimizations]
    events.c:609:11: note: within this loop
    events.c:605:49: warning: array subscript -1 is below array bounds of 'struct _Window *[16]' [-Warray-bounds]
    events.c:606:31: warning: array subscript -1 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
    events.c:610:39: warning: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
    events.c:617:38: warning: array subscript -2 is below array bounds of 'struct _Window *[16]' [-Warray-bounds]
    events.c:619:35: warning: array subscript -2 is below array bounds of 'struct _Screen *[16]' [-Warray-bounds]
    
    This results from
    
        i = PanoramiXNumScreens - 1;
    
        RegionCopy(&pSprite->Reg1, &pSprite->windows[i]->borderSize);
        off_x = screenInfo.screens[i]->x;
        off_y = screenInfo.screens[i]->y;
    
    where GCC believes that PanoramiXNumScreens might be 0. Unfortunately
    GCC is just smart enough to be an annoyance because this case is not
    actually possible: XineramaConfineCursorToWindow() is only called when
    noPanoramiXExtension is false, and if noPanoramiXExtension is false then
    PanoramiXNumScreens must be >1 (see PanoramiXExtensionInit()).
    
    So, add an assert(!noPanoramiXExtension), which to my surprise provides
    GCC with information even in release builds and lets GCC understand that
    the code is not doing anything that is undefined behavior.
    
    I chose this solution instead of the proposed assert(i >= 0) because the
    same pattern occurs in CheckVirtualMotion() but is inside an
    'if (!noPanoramiXExtension)' and does not generate any warnings.
    
    Fixes: xorg/xserver#590
    Signed-off-by: Matt Turner <mattst88 at gmail.com>

diff --git a/dix/events.c b/dix/events.c
index 98ea15b5b..f546700fa 100644
--- a/dix/events.c
+++ b/dix/events.c
@@ -597,6 +597,8 @@ XineramaConfineCursorToWindow(DeviceIntPtr pDev,
 
     int x, y, off_x, off_y, i;
 
+    assert(!noPanoramiXExtension);
+
     if (!XineramaSetWindowPntrs(pDev, pWin))
         return;
 


More information about the xorg-commit mailing list