summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuilherme Quentel Melo <gqmelo@gmail.com>2016-05-10 00:29:58 +0000
committerAdam Jackson <ajax@redhat.com>2016-07-06 13:35:30 -0400
commit54ba95861e5ae54051d3963e5e7ced7d69a6de7b (patch)
tree6b0b291a5ec9ccd46949cac7744a25499382889b
parentbe8eb5c4a1dda472d54f96bd54ee3e9421daf2e7 (diff)
downloadxserver-54ba95861e5ae54051d3963e5e7ced7d69a6de7b.tar.gz
glx: avoid memory leak when using indirect rendering
When multiple processes are using GL with indirect rendering a race condition can make drawables refcount never drop to zero. This situation could happen when there are many X clients using indirect GLX: 1 - client1: calls glXMakeCurrent 2 - client2: calls glXMakeCurrent This is the first context switch for this client. So old_context_tag=0 3 - client1: calls glXRender For the client, its context is already current. For the server side lastGLContext points to client2's context. Reviewed-by: Adam Jackson <ajax@redhat.com> Signed-off-by: Guilherme Quentel Melo <gqmelo@gmail.com> (cherry picked from commit a134d1e7eada0ac90fb622f45833c87b72c9aa06)
-rw-r--r--glx/glxext.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/glx/glxext.c b/glx/glxext.c
index e41b881f2..c201fba86 100644
--- a/glx/glxext.c
+++ b/glx/glxext.c
@@ -469,6 +469,12 @@ __glXForceCurrent(__GLXclientState * cl, GLXContextTag tag, int *error)
/* Make this context the current one for the GL. */
if (!cx->isDirect) {
+ /*
+ * If it is being forced, it means that this context was already made
+ * current. So it cannot just be made current again without decrementing
+ * refcount's
+ */
+ (*cx->loseCurrent) (cx);
lastGLContext = cx;
if (!(*cx->makeCurrent) (cx)) {
/* Bind failed, and set the error code. Bummer */