From: Frédéric Dalleau Date: Mon, 8 Jul 2013 15:32:39 +0000 (+0200) Subject: VirtGL: Fix memory leak in eglDestroyPixmap X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~749^2~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a0b68b80e374075396266d7506d0c12b03ca0fdf;p=sdk%2Femulator%2Fqemu.git VirtGL: Fix memory leak in eglDestroyPixmap The code in qemu for glXDestroyPixmap make some verifications that fails : if ( qsurface && qsurface != process->current_state->current_qsurface && qsurface->glstate == NULL && qsurface->type == SURFACE_PIXMAP) /* free image data */ We can see that before freeing surface : qemu checks that it is pixmap, it is not current and it is not bound. I added some traces and this is a sample from output : [trace:qemu:opengl][2225]> glXDestroyPixmap [trace:qemu:opengl]glXDestroyPixmap: 0x7f6898fff150 [trace:qemu:opengl]process->current_state->current_qsurface: (nil) [trace:qemu:opengl]qsurface->glstate: 0x7f689801eef0 [trace:qemu:opengl]qsurface->type: 1, SURFACE_PIXMAP: 1 [trace:qemu:opengl]process->current_state: 0x1627680, qsurface->glstate: 0x7f689801eef0 We can interpret this as : the application requested to free the surface, but it was still bound in the context. The two following reasons suggest to resolve the leak by forcing unbinding the image from qemu. * Having a destroyed image in a context doesn't really make sense, * In this use case it is likely that the context will be destroyed soon after the pixmap. --- diff --git a/tizen/src/hw/opengl_exec.c b/tizen/src/hw/opengl_exec.c index 3518cafd49..b28077cfd4 100644 --- a/tizen/src/hw/opengl_exec.c +++ b/tizen/src/hw/opengl_exec.c @@ -2105,6 +2105,10 @@ int do_function_call(ProcessState *process, int func_number, unsigned long *args /* glXPixmap same as input Pixmap */ ClientGLXDrawable client_drawable = to_drawable(args[1]); QGloSurface *qsurface = find_qsurface_from_client_drawable(process, client_drawable); + if (qsurface->glstate != NULL) { + unbind_qsurface(qsurface->glstate, qsurface); + } + if ( qsurface && qsurface != process->current_state->current_qsurface && qsurface->glstate == NULL &&