<div dir="ltr"><div>Hi Rick,<br></div>If you file a bug report it will usually get looked at by the necessary devs.  If you don't hear anything back on the bug after a few days then try the dev list directly.  You can also check the IRC channel #dri-devel on freenode.<br><div><div><div class="gmail_extra"><br>- Chuck<br><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Jun 13, 2017 at 12:10 PM, Rick Irons <span dir="ltr"><<a href="mailto:Rick.Irons@mathworks.com" target="_blank">Rick.Irons@mathworks.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div link="#0563C1" vlink="#954F72" lang="EN-US">
<div class="m_7697754784556406034m_-970683096374849885WordSection1">
<p class="MsoNormal">Hi all,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Any thoughts on the issue identified below? <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Perhaps this issue is something for the mesa-dev mailing list.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Rick<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div style="border:none;border-top:solid #e1e1e1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Rick Irons <br>
<b>Sent:</b> Friday, June 9, 2017 5:59 PM<br>
<b>To:</b> <a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.o<wbr>rg</a><br>
<b>Subject:</b> Mesa XWindows memory leak causing application instability<u></u><u></u></p>
</div>
</div><div><div class="m_7697754784556406034h5">
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">We are encountering sporadic application instability with an XWindows based implementation of Mesa.  The source of the instability appears to be a memory leak.  The details of our investigation are included below.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">This issue appears to have been introduced in Mesa 8.0.0 and is present in the current 17.1.2 release.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Our workaround is identified below.  We are interested to know if this is a valid fix or if there is an alternative preferred approach to addressing the problem.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks for any help that you can provide.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Rick<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>Problem description:<u></u><u></u></b></p>
<p class="MsoNormal">It looks like Mesa is dependent on MIT-SHM extension in the sense that if the MIT-SHM loads, it needs to be left in the same state such that Mesa's call to XShmDetatch() works correctly, with no unintended side-effects.<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in"><u></u> <u></u></p>
<p class="MsoNormal">The order of extension "close" callbacks appear to be driven by a loop in XCloseDisplay() where "Display *" points to a linked-list identified in the "ext_procs" field.<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in"><u></u> <u></u></p>
<p class="MsoNormal">We find that in Mesa’s current state, MIT-SHM's close_display extension hook is called _before_ Mesa's extension hook has been called. Thus, MIT-SHM's shm_info has removed/deleted the _XExtDisplayInfo entry associated with the Display *
 being closed _before_ Mesa has called XShmDetach as part of its close callback.<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in"><u></u> <u></u></p>
<p class="MsoNormal">The effect is to create a new _XExtDisplayInfo pointer that's left pointing to a freed "codes" field. If the _next_ caller of XOpenDisplay() is unlucky enough to a) obtain a recycled address of a "Display *" matching the previous one and
 b) call XShmQueryVersion(), there is a chance that the "codes" value(s) have been overwritten resulting in XError of BadRequest, BadLength, or hanging (all have been observed).  This appears to be what
<a href="https://github.com/mesa3d/mesa/commit/0a20051e6da99e91b7bf589ea457c77a8b618f26" target="_blank">
https://github.com/mesa3d/mesa<wbr>/commit/0a20051e6da99e91b7bf58<wbr>9ea457c77a8b618f26</a> alludes to. In fact, I added XShmQueryVersion() back in to xm_api.c, removed the XShmQueryVersion() I'd incorporated into glxgears-based test program, and reproduced this failure:<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal" style="text-indent:.5in">X Error of failed request:  BadRequest (invalid request code or no such operation)<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in">Major opcode of failed request:  0 ()<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in">Serial number of failed request:  17<u></u><u></u></p>
<p class="MsoNormal" style="text-indent:.5in">Current serial number in output stream:  17      
<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">which is exactly what we see when our glxgears-based test program calls XShmQueryVersion() after a few loops.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>Reproduction:<u></u><u></u></b></p>
<p class="MsoNormal">See the modified "glxgears" demo. If possible, run on Debian 8.3 and keep hitting escape to close the current gears demo window and advance the loop.  <u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><b>Possible workaround:<u></u><u></u></b></p>
<p class="MsoNormal">If src/mesa/drivers/x11/fakeglx.c references MIT-SHM _before_ registering itself as an extension with the current display, this appears to allow Mesa's call to XShmDetach to occur with no unintended consequence.  MIT-SHM's close callback
 is called _after_ Mesa has performed its clean up and we see no stranded entries in shm_info associated with the current display.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div></div></div>
</div>

<br>______________________________<wbr>_________________<br>
mesa-users mailing list<br>
<a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.o<wbr>rg</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-users" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-users</a><br>
<br></blockquote></div><br></div></div></div></div>