[Xcb] [PATCH] LockDisplay/UnlockDisplay in libXi

Magnus Kessler Magnus.Kessler at gmx.net
Fri Oct 13 00:49:30 PDT 2006


Here's a patch for a locking bug in libXi. It was discovered through a crash 
of the LastFM player (media-sound/lastfmplayer- on gentoo).

The function XInput_find_display() must not be called with a lock being 
held. The function _XiGetExtensionVersion() therefore only applies the lock 
afterwards. However, throughout the code base before 
_XiGetExtensionVersion() is called the callers have the lock set. 

This is further complicated by the fact that _XiGetExtensionVersion() calls 
into _XiCheckInit() which then in turn calls _XiGetExtensionVersion() with 
a different parameter. _XiCheckInit() may have some nasty side effects 
because it releases the lock under certain conditions.

This patch tries to address the immediate issue by releasing the lock in 
_XiGetExtensionVersion() before calling XInput_find_display(). libXi's lock 
handling would benefit from a closer review, though.

Could you please review and apply?

Many thanks,

Magnus Kessler

diff -u libXi-1.0.1.old/src/XGetVers.c libXi-1.0.1.new/src/XGetVers.c
--- libXi-1.0.1.old/src/XGetVers.c	2006-03-31 15:50:24.000000000 +0100
+++ libXi-1.0.1.new/src/XGetVers.c	2006-10-13 00:47:56.000000000 +0100
@@ -80,8 +80,11 @@
     xGetExtensionVersionReq *req;
     xGetExtensionVersionReply rep;
     XExtensionVersion *ext;
-    XExtDisplayInfo *info = XInput_find_display(dpy);
+    XExtDisplayInfo *info;
+    UnlockDisplay(dpy);
+    info = XInput_find_display(dpy);
+    LockDisplay(dpy);
     if (_XiCheckExtInit(dpy, Dont_Check) == -1)
 	return ((XExtensionVersion *) NoSuchExtension);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/xcb/attachments/20061013/9334d121/attachment.pgp

More information about the Xcb mailing list