[ananaza at iki.fi: X locking]

Daniel Stone daniel at fooishbar.org
Sun May 22 18:30:17 PDT 2005


FYI

----- Forwarded message from Antti P Miettinen <ananaza at iki.fi> -----

To: ubuntu-devel at lists.ubuntu.com
From: Antti P Miettinen <ananaza at iki.fi>
Date: 22 May 2005 21:46:38 +0300
Message-ID: <87br732j5d.fsf at marilyn.dna.fi>
Subject: X locking
List-Id: Ubuntu Developer Discussion <ubuntu-devel.lists.ubuntu.com>

The following would catch programs calling XInitThreads() too late. If
the lock remains uninitialized we get random memory references. Null
pointer ref should segfault reliably.

--- xorg-6.8.2/build-tree/xc/lib/X11/Xlibint.h~	2005-02-17 02:34:25.000000000 +0200
+++ xorg-6.8.2/build-tree/xc/lib/X11/Xlibint.h	2005-05-22 20:54:24.226001344 +0300
@@ -308,7 +308,13 @@
 #define _XLockMutex(lock)		if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
 #define _XUnlockMutex(lock)	if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
 #endif
-#define _XCreateMutex(lock)	if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
+#define _XCreateMutex(lock)			\
+do {						\
+    if (_XCreateMutex_fn)			\
+        (*_XCreateMutex_fn)(lock);		\
+    else					\
+	memset(lock, 0, sizeof(*lock));		\
+} while (0)
 #define _XFreeMutex(lock)	if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
 
 #else /* XTHREADS */


-- 
ubuntu-devel mailing list
ubuntu-devel at lists.ubuntu.com
http://lists.ubuntu.com/mailman/listinfo/ubuntu-devel

----- End forwarded message -----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.x.org/archives/xorg/attachments/20050523/c5637002/attachment.pgp>


More information about the xorg mailing list