Think i sent it to the wrong mailing list. Here we go again...
Begin forwarded message:
From: Mario Kleiner <mario.klei...@tuebingen.mpg.de> Date: July 27, 2010 2:56:04 AM GMT+02:00 To: Kristian Hogsberg <k...@bitplanet.net>, xorg-de...@lists.x.orgSubject: Bug: Deadlock for multi-threaded glx apps inside __glXInitialize()Hi KristianTesting 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" ab434f6b7641a64d30725a9ac24929240362d466The 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? If i omit XInitThreads() everything works again.thanks, -mario
0001-mesa-glx-Work-around-deadlock-on-_Xglobal_lock-in-__.patch
Description: Binary data
#0 0x0012d422 in __kernel_vsyscall () #1 0x031ccaf9 in __lll_lock_wait () from /lib/tls/i686/cmov/libpthread.so.0 #2 0x031c813b in _L_lock_748 () from /lib/tls/i686/cmov/libpthread.so.0 #3 0x031c7f61 in pthread_mutex_lock () from /lib/tls/i686/cmov/libpthread.so.0 #4 0x0310fba6 in pthread_mutex_lock () from /lib/tls/i686/cmov/libc.so.6 #5 0x0292f41f in _XLockMutex (lip=0x2a25e34) at ../../src/locking.c:107 #6 0x034729af in XextFindDisplay (extinfo=0x0, dpy=0x84debb0) at ../../src/extutil.c:232 #7 0x0344faff in DRI2FindDisplay (dpy=0x84debf0) at dri2.c:81 #8 0x0344fd6e in DRI2QueryExtension (dpy=0x84debf0, eventBase=0xbfffd9cc, errorBase=0xbfffd9c8) at dri2.c:184 #9 0x0344e653 in dri2CreateDisplay (dpy=0x84debf0) at dri2_glx.c:900 #10 0x0342a6ce in __glXInitialize (dpy=0x84debf0) at glxext.c:848 #11 0x0342764a in GetGLXPrivScreenConfig (dpy=0x84debf0, scrn=0, ppriv=0xbfffdbdc, ppsc=0xbfffdbd8) at glxcmds.c:183 #12 0x03427d46 in glXChooseVisual (dpy=0x84debf0, screen=0, attribList=0xbfffdcd8) at glxcmds.c:1495 #13 0x032dae3f in PsychOSOpenOnscreenWindow (screenSettings=0xbfffe114, windowRecord=0x8501010, numBuffers=2, stereomode=0, conserveVRAM=0) at Linux/Screen/PsychWindowGlue.c:288 #14 0x032ee883 in PsychOpenOnscreenWindow (screenSettings=0xbfffe114, windowRecord=0xbfffe110, numBuffers=2, stereomode=0, rect=0xbfffe1b0, multiSample=0, sharedContextWindow=0x0) at Common/Screen/PsychWindowSupport.c:295 #15 0x0330e57c in SCREENOpenWindow () at Common/Screen/SCREENOpenWindow.c:301 #16 0x0334b79b in mexFunction (nlhs=1, plhs=0xb5ee7018, nrhs=4, prhs=0xb5ee7008) at Common/Base/PsychScriptingGlue.cc:959 #17 0x004e0f25 in call_mex(bool, void*, octave_value_list const&, int, octave_mex_function*) () from /usr/lib/octave-3.2.3/liboctinterp.so #18 0x006f8868 in octave_mex_function::do_multi_index_op(int, octave_value_list const&) () from /usr/lib/octave-3.2.3/liboctinterp.so
********************************************************************* Mario Kleiner Max Planck Institute for Biological Cybernetics Spemannstr. 38 72076 Tuebingen Germany e-mail: mario.klei...@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)
********************************************************************* Mario Kleiner Max Planck Institute for Biological Cybernetics Spemannstr. 38 72076 Tuebingen Germany e-mail: mario.klei...@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)
------------------------------------------------------------------------------ The Palm PDK Hot Apps Program offers developers who use the Plug-In Development Kit to bring their C/C++ apps to Palm for a share of $1 Million in cash or HP Products. Visit us here for more details: http://p.sf.net/sfu/dev2dev-palm
_______________________________________________ Mesa3d-dev mailing list Mesa3d-dev@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mesa3d-dev