[PATCH 2/3] glx: Fix memory leak in context garbage collection

Eric Anholt eric at anholt.net
Mon Sep 30 11:17:39 PDT 2013


Adam Jackson <ajax at redhat.com> writes:

> I broke this, back in:
>
>     commit a48dadc98a28c969741979b70b7a639f24f4cbbd
>     Author: Adam Jackson <ajax at redhat.com>
>     Date:   Mon Mar 21 11:59:29 2011 -0400
>
> 	glx: Reimplement context tags
>
> In that, I changed the glx client state to not explicitly track the list
> of current contexts for the client (since that was what we were deriving
> tags from).  The bug was that I removed the code for same from
> glxClientCallback without noticing that it had the side effect of
> effectively de-currenting those contexts, so that ContextGone could free
> them.  So, if you had a client exit with a context still current, the
> context's memory would leak.  Not a huge deal for direct clients, but
> viciously bad for indirect, since the swrast context state at the bottom
> of Mesa is like 15M.
>
> Fix this by promoting Bool isCurrent to ClientPtr currentClient, so that
> we have a back-pointer to chase when walking the list of contexts when
> ClientStateGone happens.

Patch 1/3 is: Reviewed-by: Eric Anholt <eric at anholt.net>

But I'm lost on this one.  loseCurrent is just ->core->unbindContext,
which is mesa's dri_util.c dereferencing the drawables and calling the
driver UnbindContext, which is just _mesa_make_current(NULL, NULL, NULL)
regardless of the current context.  That doesn't seem to add up to a
savings of a leaked context per client gone (since whatever current
context that was otherwise unreferenced would get reaped at the next
makecurrent).  So I'm pretty sure I'm missing something.

Also, you've got some fresh tab indentation in the last hunk.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.x.org/archives/xorg-devel/attachments/20130930/76faed6f/attachment.pgp>


More information about the xorg-devel mailing list