Bug 30217 - Possible sources of memory leaks reported by valgrind
Summary: Possible sources of memory leaks reported by valgrind
Status: RESOLVED FIXED
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i915 (show other bugs)
Version: unspecified
Hardware: Other All
: medium normal
Assignee: Eric Anholt
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-15 16:23 UTC by jpsinthemix
Modified: 2011-07-07 15:19 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments

Description jpsinthemix 2010-09-15 16:23:44 UTC
In Mesa-7.8.3-rc1/src/mesa/drivers/dri/intel/intel_context.c, &intel->ViewportMatrix is allocated

123    _math_matrix_ctr(&intel->ViewportMatrix);

but does not appear to ever be released. Valgrind reports a memory leak associated with this _math_matrix_ctr call.

To address this, I added the following lines (*), which appears to fix this, but this may not be the appropriate place to do this:

837 
838       driDestroyOptionCache(&intel->optionCache);
839
*         /* free ViewportMatrix resources */ 
*         _math_matrix_dtr(&intel->ViewportMatrix);
*
840       /* free the Mesa context */
841       _mesa_free_context_data(&intel->ctx);
842 
843       FREE(intel);
844       driContextPriv->driverPrivate = NULL;

-----------------------------------------------------------------------
In Mesa-7.8.3-rc1/src/mesa/drivers/dri/intel/intel_fbo.c, there are cases where
intel_delete_renderbuffer is entered when intel != true but irb->region = true.
Valgrind reports a memory leak associated with this. To address this, I added the following lines (*), which appears to fix this, but this may not be a correct/proper thing to do:

 65 /** Called by gl_renderbuffer::Delete() */
 66 static void
 67 intel_delete_renderbuffer(struct gl_renderbuffer *rb)
 68 {
 69    GET_CURRENT_CONTEXT(ctx);
 70    struct intel_context *intel = intel_context(ctx);
 71    struct intel_renderbuffer *irb = intel_renderbuffer(rb);
 72 
 73    ASSERT(irb);
 74 
*75    //if (intel && irb->region) {
*      if (irb->region) {
 76       intel_region_release(&irb->region);
 77    }
 78 
 79    free(irb);
 80 }

thanks for your time
John
Comment 1 Eric Anholt 2011-07-07 15:19:55 UTC
commit f39476b234960cd0fb794a43a3eece440367cba2
Author: John <jpsinthemix@verizon.net>
Date:   Wed Jun 29 11:45:04 2011 -0700

    i915: Fix leak of ViewportMatrix data on context destroy.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=30217

commit 007c2d6cd2f6b206564689ac12a3e51aaae242bc
Author: Eric Anholt <eric@anholt.net>
Date:   Wed Jun 29 11:37:35 2011 -0700

    intel: Remove gratuitous context checks in intel_delete_renderbuffer().
    
    Even if we don't have a current context, if we're freeing the rb we
    should free its region (and BO).  The renderbuffer unreference checks
    appear to be just cargo-cult from the region unreference code.
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=30217
    Reviewed-by: Chad Versace <chad@chad-versace.us>


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.