[Bug 105237] xcb_wait_for_reply makes valgrind report memory leaks on Mesa driver

[email protected]
Newsgroups gmane.comp.freedesktop.xcb
Message-ID <[email protected]/>
https://bugs.freedesktop.org/show_bug.cgi?id=105237

--- Comment #2 from Maxim Filippenko <[email protected]> ---
I have a similar problem in my project. I build last xcb (version 1.12) and
mesa (version 17.2.0-devel) with -ggdb and -fsanitize=address (use gcc
sanitizer).

Indirect leak of 689436 byte(s) in 19151 object(s) allocated from:
    #0 0x7f9af0728602 in malloc
(/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x7f9aec122424 in read_packet
/home/filippenko/Soft/libxcb-1.12/src/xcb_in.c:259
    #2 0x7f9aec12613a in _xcb_in_read
/home/filippenko/Soft/libxcb-1.12/src/xcb_in.c:1012
    #3 0x7f9aec11e560 in _xcb_conn_wait
/home/filippenko/Soft/libxcb-1.12/src/xcb_conn.c:515
    #4 0x7f9aec1238bd in wait_for_reply
/home/filippenko/Soft/libxcb-1.12/src/xcb_in.c:516
    #5 0x7f9aec123b0a in xcb_wait_for_reply
/home/filippenko/Soft/libxcb-1.12/src/xcb_in.c:546
    #6 0x7f9ae9faf64e in xcb_dri2_swap_buffers_reply
/home/filippenko/Soft/libxcb-1.12/src/dri2.c:893
    #7 0x7f9aeec7cbcb in dri2_x11_swap_buffers_msc (lib/libEGL.so.1+0x1bbcb)
    #8 0x7f9aeec7ccce in dri2_x11_swap_buffers (lib/libEGL.so.1+0x1bcce)
    #9 0x7f9aeec77e89 in dri2_swap_buffers (lib/libEGL.so.1+0x16e89)
    #10 0x7f9aeec6b202 in eglSwapBuffers (lib/libEGL.so.1+0xa202)

Inside method xcb_wait_for_reply events are added to the linked list, but
nobody reads this list.

I tried to add a cleanup of this list:
=============================================
diff --git a/src/egl/drivers/dri2/platform_x11.c
b/src/egl/drivers/dri2/platform_x11.c
index b01f739..1d1271d 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -869,6 +869,12 @@ dri2_x11_swap_buffers_msc(_EGLDriver *drv, _EGLDisplay
*disp, _EGLSurface *draw,

    reply = xcb_dri2_swap_buffers_reply(dri2_dpy->conn, cookie, NULL);

+   xcb_generic_event_t * event = xcb_poll_for_event(dri2_dpy->conn);
+   while (event) {
+      free(event);
+      event = xcb_poll_for_event(dri2_dpy->conn);
+   }
+
    if (reply) {
       swap_count = (((int64_t)reply->swap_hi) << 32) | reply->swap_lo;
       free(reply);
===============================================

After that the problem (memory leak) is not observed yet.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.

_______________________________________________
Xcb mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/xcb
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.