Hi,

There is a bug in _XEventsQueued() that causes an 'event reader lock' of
another thread to be released. This can cause a hang and keyboard lockup
in KDE. For example, using KDE CVS and xine CVS, by playing a movie clip
with Noatun (hang and keyboard lockup after playback has stopped).

The attached patch should fix this problem by freeing the event reader
lock _only_ when it was previously acquired within the function. This seems
to fix at least xterm and KDE/xine hang and keyboard lockup problems.

I really hope this fix can still be in XFree86 4.3.0, as it seems to
affect many other applications. Any multi-threaded application using Xlib
could experience this problem, and at least xterm is affected as well.

Thanks in advance.
bye,

ewald
--- XFree86-4.2.99.901/xc/lib/X11/XlibInt.c.ori	2002-11-22 17:58:13.000000000 +0100
+++ XFree86-4.2.99.901/xc/lib/X11/XlibInt.c	2003-02-12 10:16:33.000000000 +0100
@@ -778,7 +778,9 @@
 #endif /* XCONN_CHECK_FREQ */
 	if (!(len = pend)) {
 	    /* _XFlush can enqueue events */
-	    UnlockNextEventReader(dpy);
+	    if (cvl) {
+		UnlockNextEventReader(dpy);
+	    }
 	    return(dpy->qlen);
 	}
       /* Force a read if there is not enough data.  Otherwise,
@@ -822,7 +824,9 @@
 		if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
 		    memcpy(dpy->lock->reply_awaiters->buf, read_buf,
 			   len);
-		UnlockNextEventReader(dpy);
+		if (cvl) {
+		    UnlockNextEventReader(dpy);
+		}
 		return(dpy->qlen); /* we read, so we can return */
 	    } else if (read_buf != buf.buf)
 		memcpy(buf.buf, read_buf, len);
@@ -846,7 +850,9 @@
 	    }
 	} ENDITERATE
 
-	UnlockNextEventReader(dpy);
+	if (cvl) {
+	    UnlockNextEventReader(dpy);
+	}
 	return(dpy->qlen);
 }
 

Reply via email to