<div dir="ltr">Hi,<div class="gmail_extra"><br><div class="gmail_quote">On 24 October 2014 11:03, Kalyan Kondapally <span dir="ltr"><<a href="mailto:kondapallykalyancontribute@gmail.com" target="_blank">kondapallykalyancontribute@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">driUnbindContext() checks for valid drawables before calling the driver<br>
unbind function. In case of Surfaceless contexts, the drawables are always<br>
Null and we end up not releasing the underlying DRI context. Moving the<br>
call to the driver function before the drawable validity checks fixes things.<br></blockquote><div><br></div><div>Yep, that looks good to me; seems like you've found the only possible case that would trigger this breakage. Calling DestroyContext will always unbind if it's current in that thread (see the end _mesa_free_context_data); it's only when you follow that exact pattern of:</div><div>  - create surfaceless context</div><div>  - make ctx current</div><div>  - make something else current</div><div>  - {another thread} destroy ctx</div><div>  - make ctx current again</div><div>that you hit the crash.</div><div><br></div><div>The only effect of calling UnbindContext() is that _mesa_make_current(NULL, NULL, NULL) gets called, which is what we want.</div><div><br></div><div>Could you please document some part of that in the commit message for future archaeology?</div><div><br></div><div>Reviewed-by: Daniel Stone <<a href="mailto:daniels@collabora.com">daniels@collabora.com</a>></div><div><br></div><div>Cheers,</div><div>Daniel</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Signed-off-by: Alexandros Frantzis <<a href="mailto:Alexandros.Frantzis@canonical.com">Alexandros.Frantzis@canonical.com</a>><br>
Signed-off-by: Kalyan Kondapally <<a href="mailto:kalyan.kondapally@intel.com">kalyan.kondapally@intel.com</a>><br>
Bugzilla: <a href="https://bugs.freedesktop.org/show_bug.cgi?id=74563" target="_blank">https://bugs.freedesktop.org/show_bug.cgi?id=74563</a><br>
---<br>
 src/mesa/drivers/dri/common/dri_util.c | 8 ++++++--<br>
 1 file changed, 6 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c<br>
index 6c78928..02499f2 100644<br>
--- a/src/mesa/drivers/dri/common/dri_util.c<br>
+++ b/src/mesa/drivers/dri/common/dri_util.c<br>
@@ -569,6 +569,12 @@ static int driUnbindContext(__DRIcontext *pcp)<br>
     if (pcp == NULL)<br>
        return GL_FALSE;<br>
<br>
+    /*<br>
+    ** Call driUnbindContext before checking for valid drawables<br>
+    ** to handle surfaceless contexts properly.<br>
+    */<br>
+    pcp->driScreenPriv->driver->UnbindContext(pcp);<br>
+<br>
     pdp = pcp->driDrawablePriv;<br>
     prp = pcp->driReadablePriv;<br>
<br>
@@ -576,8 +582,6 @@ static int driUnbindContext(__DRIcontext *pcp)<br>
     if (!pdp && !prp)<br>
        return GL_TRUE;<br>
<br>
-    pcp->driScreenPriv->driver->UnbindContext(pcp);<br>
-<br>
     assert(pdp);<br>
     if (pdp->refcount == 0) {<br>
        /* ERROR!!! */<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.9.1<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div></div>