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

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Wed Feb 28 16:12:47 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=105237

--- Comment #2 from Maxim Filippenko <max.filippenko at gmail.com> ---
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/xcb/attachments/20180228/f10ef962/attachment.html>


More information about the Xcb mailing list