Bug: Deadlock for multi-threaded glx apps inside __glXInitialize()
Mario Kleiner
mario.kleiner at tuebingen.mpg.de
Mon Jul 26 17:56:04 PDT 2010
Hi Kristian
Testing with current mesa master, my toolkit deadlocks on the first
call to a glX function (glXChooseVisual()).
The deadlock was probably introduced by your recent commit:
"glx: Use _Xglobal_lock for protecting extension display list"
ab434f6b7641a64d30725a9ac24929240362d466
The problem is that the _Xglobal_lock is locked twice inside the
__glXInitialize() function of mesa/src/glx/glxext.c, once inside
__glXInitialize(), and then as part of dri2CreateDisplay() -> ... ->
XextFindDisplay. The 2nd locking call on the already held lock
deadlocks.
Attached a backtrace with the problem and a patch/hack that "fixes"
it for me, but introduces a race-condition itself, so this is
obviously not the correct solution. The race condition would trigger
if two threads would simultaneously do their first call to a glX
function for the same Display* dpy handle, rather unlikely to happen
in practice? If so, then the patch might be an acceptable fix until
a better solution is found?
Other applications (glxgears, games etc.) work correctly. The
difference is that my toolkit calls XInitThreads() at startup to use
xlib multi-threaded and afaik the locking calls only get enabled if
xlib is switched to thread-safe mode, otherwise they are no-ops?
thanks,
-mario
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-mesa-glx-Work-around-deadlock-on-_Xglobal_lock-in-__.patch
Type: application/octet-stream
Size: 1780 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100727/fcb2ea31/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: PsychtoolboxDeadlockIn__glXInitialize_Backtrace.txt
URL: <http://lists.x.org/archives/xorg-devel/attachments/20100727/fcb2ea31/attachment.txt>
-------------- next part --------------
*********************************************************************
Mario Kleiner
Max Planck Institute for Biological Cybernetics
Spemannstr. 38
72076 Tuebingen
Germany
e-mail: mario.kleiner at tuebingen.mpg.de
office: +49 (0)7071/601-1623
fax: +49 (0)7071/601-616
www: http://www.kyb.tuebingen.mpg.de/~kleinerm
*********************************************************************
"For a successful technology, reality must take precedence
over public relations, for Nature cannot be fooled."
(Richard Feynman)
More information about the xorg-devel
mailing list