Skip to content
  • Adam Jackson's avatar
    glx: Fix memory leak in context garbage collection (v2) · 276d8057
    Adam Jackson authored
    I broke this, back in:
    
        commit a48dadc9
        Author: Adam Jackson <ajax@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.
    
    v2: Explicitly call __glXFreeContext on the ClientStateGone path.  Our
    current context might be one we got from EXT_import_context and whose
    creating client has since died.  Without the explicit call, the creating
    client's FreeClientResources would not free the context because it's
    still current, and the using client's FreeClientResources would not free
    the context because it's not an XID it created.  This matches the logic
    from a48dadc9
    
    .
    
    Reviewed-by: default avatarIan Romanick <ian.d.romanick@intel.com>
    Signed-off-by: default avatarAdam Jackson <ajax@redhat.com>
    276d8057