<div dir="ltr"><div><div>I've finally got some time to rewrite this patch and now the solution makes more sense.<br></div>I'm sending as an attachment.<br></div>I also have some tests on a github repository to check this bug. I don't know if it is ok to post the link here though.<br><div><div><div><br><br></div><div>Guilherme<br></div><div><br><div class="gmail_quote"><div dir="ltr">On Tue, Dec 8, 2015 at 4:48 PM Guilherme Melo <<a href="mailto:gqmelo@gmail.com">gqmelo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">This should be lastGLContext->loseCurrent(lastGLContext) I think. cx</blockquote><div><br></div></div></div><div dir="ltr"><div><div>Yes, you are right. It seems the right thing to do, but actually this should be done every place where lastGLContext is set, right?<br></div><div>It seems to me that every place where lastGLContext is set is a potential leak.<br></div><div></div></div></div><div dir="ltr"><div><div><br><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">While you're at it, it'd be nice to move that big block comment into the commit message</blockquote><div><br></div></div></div></div><div dir="ltr"><div><div><div>I'll do that, thanks. <br></div></div><br><br></div></div><div dir="ltr">Guilherme</div><div dir="ltr"><br><br><div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-08 14:44 GMT-02:00 Adam Jackson <span dir="ltr"><<a href="mailto:ajax@nwnk.net" target="_blank">ajax@nwnk.net</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div>On Fri, 2015-12-04 at 14:16 -0200, Guilherme Quentel Melo wrote:<br>
<br>
> diff --git a/glx/glxext.c b/glx/glxext.c<br>
> index e41b881..16b8039 100644<br>
> --- a/glx/glxext.c<br>
> +++ b/glx/glxext.c<br>
> @@ -469,6 +469,24 @@ __glXForceCurrent(__GLXclientState * cl, GLXContextTag tag, int *error)<br>
>  <br>
>      /* Make this context the current one for the GL. */<br>
>      if (!cx->isDirect) {<br>
> +        /*<br>
> +         ** If we are forcing the context it means someone already called makeCurrent before. If<br>
> +         ** we just call makeCurrent again, the drawable of this context will be left with one<br>
> +         ** refcount more forever and will never be freed.<br>
> +         **<br>
> +         ** This situation happens when there are many X clients using GL:<br>
> +         **<br>
> +         ** 1 - client1: calls glXMakeCurrent<br>
> +         **<br>
> +         ** 2 - client2: calls glXMakeCurrent<br>
> +         **     This is the first context switch for this client. So old_context_tag=0<br>
> +         **<br>
> +         ** 3 - client1: calls glXRender<br>
> +         **     For the client, its context is already current.<br>
> +         **     For the server side lastGLContext points to client2's context. So the execution path<br>
> +         **     will get here.<br>
> +         */<br>
> +        (*cx->loseCurrent) (cx);<br>
<br>
</div></div>This should be lastGLContext->loseCurrent(lastGLContext) I think. cx<br>
here is the current context from client2's perspective, you want to<br>
release client1's context.<br>
<br>
While you're at it, it'd be nice to move that big block comment into<br>
the commit message and just note /* drop previous client's context */<br>
or similar in the code.<br>
<br>
- ajax</blockquote></div><br></div></div></div></blockquote></div></div></div></div></div>