<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - xcb_wait_for_reply makes valgrind report memory leaks on Mesa driver"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=105237">105237</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>xcb_wait_for_reply makes valgrind report memory leaks on Mesa driver
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>XCB
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>1.11
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86-64 (AMD64)
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>critical
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Library
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>xcb@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>94389147@qq.com
          </td>
        </tr>

        <tr>
          <th>QA Contact</th>
          <td>xcb@lists.freedesktop.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Hi all,
   I used valgrind to test my app's memory leak on ubuntu 16.04/amd64. In the
report, it gives me following callstacks about leaking.

==3307== 324 bytes in 9 blocks are definitely lost in loss record 704 of 901
==3307==    at 0x4C2DB8F: malloc (in
/usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==3307==    by 0xC23314B: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==3307==    by 0xC230ED0: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==3307==    by 0xC232616: ??? (in /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==3307==    by 0xC232720: xcb_wait_for_reply (in
/usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0)
==3307==    by 0xFFE21F1: dri3_update_drawable.isra.9
(loader_dri3_helper.c:1205)
==3307==    by 0xFFE361C: loader_dri3_get_buffers (loader_dri3_helper.c:1556)
==3307==    by 0x11CAC63C: intel_update_image_buffers (brw_context.c:1707)
==3307==    by 0x11CAC63C: intel_update_renderbuffers (brw_context.c:1383)
==3307==    by 0x11CACB10: intel_prepare_render (brw_context.c:1404)
==3307==    by 0x11CACBD2: intelMakeCurrent (brw_context.c:1242)
==3307==    by 0x11C6C9B5: driBindContext (dri_util.c:585)
==3307==    by 0xFFDDC95: dri3_bind_context (dri3_glx.c:199)

It seems the xcb_wait_for_reply calling caused the memory leak on my machine. I
delved into direct caller function in loader_dri3_helper.c:1205.
It's as following,

.....
1203       geom_cookie = xcb_get_geometry(draw->conn, draw->drawable);
1204 
1205       geom_reply = xcb_get_geometry_reply(draw->conn, geom_cookie, NULL);
1206 
1207       if (!geom_reply) {
1208          mtx_unlock(&draw->mtx);
1209          return false;
1210       }
1211 
1212       draw->width = geom_reply->width;
1213       draw->height = geom_reply->height;
1214       draw->depth = geom_reply->depth;
1215       draw->vtable->set_drawable_size(draw, draw->width, draw->height);
1216 
1217       free(geom_reply);
....

These is a free(geom_reply) to release resource in 1217 line. And I don't know
why valgrind doesn't count the free calling. It seems
xcb_get_geometry_reply/xcb_wait_for_reply not really reply and hanging there?

Jiancong</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
          <li>You are the QA Contact for the bug.</li>
      </ul>
    </body>
</html>