<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Hi Chuck,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">One of my colleagues tried the configuration that you recommended and was unable to reproduce the issue.  On further investigation he determined that the Gallium configuration
 doesn’t call </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">XShmDetach.  He added a call to XShmDetach and was then able to recreate the issue.  Is it intentional (and appropriate) that the XShmDetach call is absent from the Gallium
 configuration?</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Rick<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Chuck Atkins [mailto:chuck.atkins@kitware.com]
<br>
<b>Sent:</b> Friday, June 16, 2017 8:44 PM<br>
<b>To:</b> Rick Irons <Rick.Irons@mathworks.com><br>
<b>Cc:</b> Brian Paul <brianp@vmware.com>; mesa-users@lists.freedesktop.org<br>
<b>Subject:</b> Re: [Mesa-users] Mesa XWindows memory leak causing application instability<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<p class="MsoNormal">Hi Rick,<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt">Do you have the same problem if you use the gallium-xlib driver instead? Try with a bare-bones gallium-xlib configuration (only the softpipe driver):<br>
<br>
./configure --enable-opengl --disable-gles1 --disable-gles2 --disable-dri --disable-egl --disable-gbm --enable-glx=gallium-xlib --disable-llvm --disable-shared-glapi --disable-va --disable-xvmc --disable-vdpau --with-gallium-drivers=swrast --with-platforms=x11<o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt">- Chuck<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">On Fri, Jun 16, 2017 at 4:17 PM, Rick Irons <<a href="mailto:Rick.Irons@mathworks.com" target="_blank">Rick.Irons@mathworks.com</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Hi Brian,<br>
<br>
We are using the old Mesa Xlib driver.  The configure options we use are the following...<br>
<br>
        ./autogen.sh --enable-glx=xlib --disable-driglx-direct --disable-dri --without-gallium-drivers --disable-egl --disable-gbm -with-platforms=x11<br>
<br>
Output of glxinfo is attached.<br>
<br>
Thanks,<br>
Rick<o:p></o:p></p>
<div>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><br>
-----Original Message-----<br>
From: Brian Paul [mailto:<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>]<br>
Sent: Friday, June 16, 2017 4:06 PM<br>
To: Rick Irons <<a href="mailto:Rick.Irons@mathworks.com" target="_blank">Rick.Irons@mathworks.com</a>><br>
Cc: Chuck Atkins <<a href="mailto:chuck.atkins@kitware.com" target="_blank">chuck.atkins@kitware.com</a>>;
<a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.org</a><br>
Subject: Re: [Mesa-users] Mesa XWindows memory leak causing application instability<br>
<br>
Rick,<br>
<br>
Which Mesa driver are you using?  What's the output of glxinfo?<br>
<br>
Both the old Mesa Xlib driver and the newer gallium softpipe/llvmpipe drivers use XShm and I'm not sure which one you're using.<br>
<br>
-Brian<br>
<br>
On 06/16/2017 01:28 PM, Chuck Atkins wrote:<br>
> Hi Rick,<br>
> If you file a bug report it will usually get looked at by the<br>
> necessary devs.  If you don't hear anything back on the bug after a<br>
> few days then try the dev list directly.  You can also check the IRC<br>
> channel #dri-devel on freenode.<br>
><br>
> - Chuck<br>
><br>
> On Tue, Jun 13, 2017 at 12:10 PM, Rick Irons <<a href="mailto:Rick.Irons@mathworks.com" target="_blank">Rick.Irons@mathworks.com</a><br>
> <mailto:<a href="mailto:Rick.Irons@mathworks.com" target="_blank">Rick.Irons@mathworks.com</a>>> wrote:<br>
><br>
>     Hi all,____<br>
><br>
>     __ __<br>
><br>
>     Any thoughts on the issue identified below? ____<br>
><br>
>     __ __<br>
><br>
>     Perhaps this issue is something for the mesa-dev mailing list.____<br>
><br>
>     __ __<br>
><br>
>     Thanks,____<br>
><br>
>     Rick____<br>
><br>
>     __ __<br>
><br>
>     *From:* Rick Irons<br>
>     *Sent:* Friday, June 9, 2017 5:59 PM<br>
>     *To:* <a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.org</a><br>
>     <mailto:<a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.org</a>><br>
>     *Subject:* Mesa XWindows memory leak causing application<br>
> instability____<br>
><br>
>     __ __<br>
><br>
>     Hi,____<br>
><br>
>     __ __<br>
><br>
>     We are encountering sporadic application instability with an<br>
>     XWindows based implementation of Mesa.  The source of the<br>
>     instability appears to be a memory leak.  The details of our<br>
>     investigation are included below.____<br>
><br>
>     __ __<br>
><br>
>     This issue appears to have been introduced in Mesa 8.0.0 and is<br>
>     present in the current 17.1.2 release.____<br>
><br>
>     __ __<br>
><br>
>     Our workaround is identified below.  We are interested to know if<br>
>     this is a valid fix or if there is an alternative preferred approach<br>
>     to addressing the problem.____<br>
><br>
>     __ __<br>
><br>
>     Thanks for any help that you can provide.____<br>
><br>
>     __ __<br>
><br>
>     Rick____<br>
><br>
>     __ __<br>
><br>
>     __ __<br>
><br>
>     __ __<br>
><br>
>     *Problem description:____*<br>
><br>
>     It looks like Mesa is dependent on MIT-SHM extension in the sense<br>
>     that if the MIT-SHM loads, it needs to be left in the same state<br>
>     such that Mesa's call to XShmDetatch() works correctly, with no<br>
>     unintended side-effects.____<br>
><br>
>     __ __<br>
><br>
>     The order of extension "close" callbacks appear to be driven by a<br>
>     loop in XCloseDisplay() where "Display *" points to a linked-list<br>
>     identified in the "ext_procs" field.____<br>
><br>
>     __ __<br>
><br>
>     We find that in Mesa’s current state, MIT-SHM's close_display<br>
>     extension hook is called _before_ Mesa's extension hook has been<br>
>     called. Thus, MIT-SHM's shm_info has removed/deleted the<br>
>     _XExtDisplayInfo entry associated with the Display * being closed<br>
>     _before_ Mesa has called XShmDetach as part of its close<br>
> callback.____<br>
><br>
>     __ __<br>
><br>
>     The effect is to create a new _XExtDisplayInfo pointer that's left<br>
>     pointing to a freed "codes" field. If the _next_ caller of<br>
>     XOpenDisplay() is unlucky enough to a) obtain a recycled address of<br>
>     a "Display *" matching the previous one and b) call<br>
>     XShmQueryVersion(), there is a chance that the "codes" value(s) have<br>
>     been overwritten resulting in XError of BadRequest, BadLength, or<br>
>     hanging (all have been observed).  This appears to be what<br>
>     <a href="https://github.com/mesa3d/mesa/commit/0a20051e6da99e91b7bf589ea457c77a8b618f26" target="_blank">https://github.com/mesa3d/mesa/commit/0a20051e6da99e91b7bf589ea457c77a8b618f26</a><br>
>     <<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_mesa3d_mesa_commit_0a20051e6da99e91b7bf589ea457c77a8b618f26&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=sDFaHTXy_QwKdQ0mlORDT6cCzkRnbjEwsqTMtCQJVsY&s=WErP_2_7ibjVwY_O0qnVjtrreVBAWiiSUt7LW_qKVxg&e=" target="_blank">https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_mesa3d_mesa_commit_0a20051e6da99e91b7bf589ea457c77a8b618f26&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=sDFaHTXy_QwKdQ0mlORDT6cCzkRnbjEwsqTMtCQJVsY&s=WErP_2_7ibjVwY_O0qnVjtrreVBAWiiSUt7LW_qKVxg&e=</a>><br>
>     alludes to. In fact, I added XShmQueryVersion() back in to xm_api.c,<br>
>     removed the XShmQueryVersion() I'd incorporated into glxgears-based<br>
>     test program, and reproduced this failure:____<br>
><br>
>     __ __<br>
><br>
>     X Error of failed request:  BadRequest (invalid request code or no<br>
>     such operation)____<br>
><br>
>     Major opcode of failed request:  0 ()____<br>
><br>
>     Serial number of failed request:  17____<br>
><br>
>     Current serial number in output stream:  17 ____<br>
><br>
>     __ __<br>
><br>
>     which is exactly what we see when our glxgears-based test program<br>
>     calls XShmQueryVersion() after a few loops.____<br>
><br>
>     __ __<br>
><br>
>     *Reproduction:____*<br>
><br>
>     See the modified "glxgears" demo. If possible, run on Debian 8.3 and<br>
>     keep hitting escape to close the current gears demo window and<br>
>     advance the loop. ____<br>
><br>
>     __ __<br>
><br>
>     *Possible workaround:____*<br>
><br>
>     If src/mesa/drivers/x11/fakeglx.c references MIT-SHM _before_<br>
>     registering itself as an extension with the current display, this<br>
>     appears to allow Mesa's call to XShmDetach to occur with no<br>
>     unintended consequence.  MIT-SHM's close callback is called _after_<br>
>     Mesa has performed its clean up and we see no stranded entries in<br>
>     shm_info associated with the current display.____<br>
><br>
>     __ __<br>
><br>
><br>
>     _______________________________________________<br>
>     mesa-users mailing list<br>
>     <a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.org</a><br>
>     <mailto:<a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.org</a>><br>
>     <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-users" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-users</a><br>
><br>
> <<a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedeskto" target="_blank">https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedeskto</a><br>
> p.org_mailman_listinfo_mesa-2Dusers&d=DwMFaQ&c=uilaK90D4TOVoH58JNXRgQ&<br>
> r=Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=sDFaHTXy_QwKdQ0mlORDT6<br>
> cCzkRnbjEwsqTMtCQJVsY&s=T3N_tCx9oTUNZVXOu85-SlFOD-ULhZGi8Z-_zmCcPb8&e=<br>
> ><br>
><br>
><br>
><br>
><br>
> _______________________________________________<br>
> mesa-users mailing list<br>
> <a href="mailto:mesa-users@lists.freedesktop.org" target="_blank">mesa-users@lists.freedesktop.org</a><br>
> <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop" target="_blank">
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.freedesktop</a><br>
> .org_mailman_listinfo_mesa-2Dusers&d=DwIGaQ&c=uilaK90D4TOVoH58JNXRgQ&r<br>
> =Ie7_encNUsqxbSRbqbNgofw0ITcfE8JKfaUjIQhncGA&m=sDFaHTXy_QwKdQ0mlORDT6c<br>
> CzkRnbjEwsqTMtCQJVsY&s=T3N_tCx9oTUNZVXOu85-SlFOD-ULhZGi8Z-_zmCcPb8&e=<br>
><o:p></o:p></p>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</body>
</html>