[PATCH] Return BadWindow instead of BadMatch from dixLookupWindow

Julien Cristau jcristau at debian.org
Sat Jun 5 07:41:42 PDT 2010

From: Ben Hutchings <ben at decadent.org.uk>

BadMatch is not a documented error code for XGetWindowProperty which
sends X_GetProperty requests.  However, the implementation in Xorg
appears to return BadMatch if and only if it's passed a reference to a
drawable that isn't a window.

I don't understand how the server coordinates window changes with the
WM.  Is it possible that a window can be completely deleted before the
WM has handled it?  In that case there is presumably a race condition
where a window could disppear and another drawable be created with the
same id.

I would suggest the following change.  This is untested because the
BadWindow or BadMatch error is dependent on a race condition if I
understand correctly.  But it's "obviously correct". :-)

Debian bug#491979 <http://bugs.debian.org/491979>
Ben sent this patch to the Debian bug in 2008, but this seems to still
apply to the current code.  The initial report was a ion3 crash because
it got unexpected BadMatch errors from XGetWindowProperty.

 dix/dixutils.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/dix/dixutils.c b/dix/dixutils.c
index 51dbd14..f7d032a 100644
--- a/dix/dixutils.c
+++ b/dix/dixutils.c
@@ -225,7 +225,7 @@ dixLookupWindow(WindowPtr *pWin, XID id, ClientPtr client, Mask access)
     int rc;
     rc = dixLookupDrawable((DrawablePtr*)pWin, id, client, M_WINDOW, access);
-    return (rc == BadDrawable) ? BadWindow : rc;
+    return (rc == BadDrawable || rc == BadMatch) ? BadWindow : rc;

More information about the xorg-devel mailing list