<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0"><span style="font-size: 12pt;">If the </span>
<span style="font-size: 12pt;">call to dri_destroy_buffer </span><span style="font-size: 12pt;">is delayed until the next eglMakeCurrent,
</span><span style="font-size: 12pt;">t</span><span style="font-size: 12pt;">hat would also solve the problem (I'm not sure how that would affect other things, though).</span><br>
</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">As long as dri_make_current doesn't compare against a dangling pointer, I'm happy.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">Johan</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Michel Dänzer <michel@daenzer.net><br>
<b>Sent:</b> Tuesday, April 24, 2018 10:36:00 AM<br>
<b>To:</b> Johan Helsing; Marek Olšák<br>
<b>Cc:</b> Daniel Stone; pekka.paalanen@collabora.co.uk; ML Mesa-dev<br>
<b>Subject:</b> Re: [Mesa-dev] [PATCH] st/dri: Fix dangling pointer to a destroyed dri_drawable</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On 2018-04-24 09:13 AM, Johan Helsing wrote:<br>
> Emil: Your alternative patch won't work because dri_make_current is not necessarily called with NULL after a buffer has been destroyed.<br>
> <br>
> <br>
> The problematic sequence is a pattern we use in QtWayland:<br>
> <br>
> <br>
> //create temporary context<br>
> <br>
> surface1 = eglCreateWindowSurface() <-- dri_drawable pointer is malloced<br>
> <br>
> eglMakeCurrent(surface1) <-- ctx->dPriv is set<br>
> <br>
> <br>
> // ... (Get some information about available GL extensions etc)<br>
> <br>
> <br>
> eglDestroySurface(surface1) <-- pointer is freed, ctx->dPriv is now dangling<br>
<br>
Is this the problem? The memory pointed to by ctx->dPriv shouldn't be<br>
freed as long as the surface is bound to the current context?<br>
<br>
<br>
-- <br>
Earthling Michel Dänzer | <a href="http://www.amd.com">
http://www.amd.com</a><br>
Libre software enthusiast | Mesa and X developer<br>
</div>
</span></font></div>
</body>
</html>