Bug 30457 - [7.9] DRI drawables prematurely destroyed on context switch
Summary: [7.9] DRI drawables prematurely destroyed on context switch
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: Other All
: medium normal
Assignee: mesa-dev
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-29 04:14 UTC by Christopher James Halse Rogers
Modified: 2010-09-29 06:12 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
Simpleminded patch which fixes Clutter apps. (448 bytes, patch)
2010-09-29 04:14 UTC, Christopher James Halse Rogers
Details | Splinter Review

Description Christopher James Halse Rogers 2010-09-29 04:14:54 UTC
Created attachment 39044 [details] [review]
Simpleminded patch which fixes Clutter apps.

It seems that with the new GLX drawable garbage collection that mesa incorrectly destroys drawables when switching a single context between drawables.

This manifests in some clutter applications crashing with a BadDrawable error:
(quadrapassel:4883): ClutterGLX-CRITICAL **: Unable to make the stage window 0x4800005 the current GLX drawable

(quadrapassel:4883): ClutterGLX-CRITICAL **: Unable to make the stage window 0x4800006 the current GLX drawable

(quadrapassel:4883): ClutterGLX-CRITICAL **: Unable to make the stage window 0x4800006 the current GLX drawable
The program 'quadrapassel' received an X Window System error.
This probably reflects a bug in the program.
The error was 'BadDrawable (invalid Pixmap or Window parameter)'.
  (Details: serial 70 error_code 9 request_code 137 minor_code 12)
  (Note to programmers: normally, X errors are reported asynchronously;
   that is, you will receive the error a while after causing it.
   To debug your program, run it with the --sync command line
   option to change this behavior. You can then get a meaningful
   backtrace from your debugger if you break on the gdk_x_error() function.)

The cause is that when dri2_unbind_context is called with new context == old context it calls driReleaseDrawable.  Clutter will switch a single context between different drawables with glXMakeCurrent, so it hits this codepath.  When it switches back to the original drawable, mesa only has the GLXDrawable id which doesn't match the X drawable ID, and hence calls using it result in BadDrawable in clutter.

I've sent a piglit testcase to the piglit list exhibiting this bug.

The attached patch fixes this, but probably leaks drawables.
Comment 1 Kristian Høgsberg 2010-09-29 06:12:56 UTC
4b70fe8421f5132c585ff1dfb8d90229be26e71f should fix the clutter issue, but the piglit test you sent tests something different.  If you look at the actual X errors, the clutter problem comes from glXMakeCurrent getting a BadDrawable, the test case fails in glXSwapBuffers.  To test the clutter problem you'll have to create two GLXDrawables (A and B) and then make a context current with A, then B, then switch back to A.  If you have time to write up a test case for this, that would be much appreciated.

The swapbuffer problem is still present, and I've committed the test case to piglit, but it's a much rarer case to hit.  Few applications do glXSwapBuffer for a drawable that's not also current, but it has to work, of course.

The clutter problem is fixed (reproduced using test-multistage) and cherry-picked back to 7.9 (b24238c49abf9b6aaaac56ffbf45a3c203c7ddd2) so I'll close this bug.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.