<div dir="ltr"><div>I think the problem is _DrawArrays points to a deleted VAO, because we don't reset _DrawArrays to NULL. The attached patch should fix it. Please review.<br><br></div>Marek<br></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Mon, Apr 15, 2013 at 7:56 PM, Fredrik Höglund <span dir="ltr"><<a href="mailto:fredrik@kde.org" target="_blank">fredrik@kde.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Otherwise gl_array_attrib::_DrawArrays can end up pointing at free'd<br>
memory when the array object is deleted.<br>
<br>
Note: This is a candidate for the stable branches.<br>
---<br>
<br>
The slightly longer explanation is that the mesa state tracker accesses<br>
_DrawArrays during state validation, and state validation can be<br>
triggered between draw calls. So the following sequence of calls will<br>
result in a segfault if the VAO being deleted is the VAO that was used<br>
in the last draw call:<br>
<br>
glDeleteVertexArrays(...);<br>
glClear();<br>
<br>
src/mesa/main/context.c | 1 +<br>
src/mesa/main/mtypes.h | 5 +++++<br>
src/mesa/vbo/vbo_exec_array.c | 3 +++<br>
3 files changed, 9 insertions(+)<br>
<br>
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c<br>
index d77740e..a03a22d 100644<br>
--- a/src/mesa/main/context.c<br>
+++ b/src/mesa/main/context.c<br>
@@ -1160,6 +1160,7 @@ _mesa_free_context_data( struct gl_context *ctx )<br>
<br>
_mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, NULL);<br>
_mesa_reference_array_object(ctx, &ctx->Array.DefaultArrayObj, NULL);<br>
+ _mesa_reference_array_object(ctx, &ctx->Array.DrawArrayObj, NULL);<br>
<br>
_mesa_free_attrib_data(ctx);<br>
_mesa_free_buffer_objects(ctx);<br>
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h<br>
index e46fa39..6fb5c79 100644<br>
--- a/src/mesa/main/mtypes.h<br>
+++ b/src/mesa/main/mtypes.h<br>
@@ -1555,6 +1555,11 @@ struct gl_array_attrib<br>
* Vertex arrays as consumed by a driver.<br>
* The array pointer is set up only by the VBO module. */<br>
const struct gl_client_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */<br>
+<br>
+ /**<br>
+ * The vertex array object that contains the arrays pointed to by _DrawArrays.<br>
+ */<br>
+ struct gl_array_object *DrawArrayObj;<br>
};<br>
<br>
<br>
diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c<br>
index 7e61f7b..2bcf1b4 100644<br>
--- a/src/mesa/vbo/vbo_exec_array.c<br>
+++ b/src/mesa/vbo/vbo_exec_array.c<br>
@@ -35,6 +35,7 @@<br>
#include "main/enums.h"<br>
#include "main/macros.h"<br>
#include "main/transformfeedback.h"<br>
+#include "main/arrayobj.h"<br>
<br>
#include "vbo_context.h"<br>
<br>
@@ -499,6 +500,8 @@ vbo_bind_arrays(struct gl_context *ctx)<br>
<br>
vbo_draw_method(vbo, DRAW_ARRAYS);<br>
<br>
+ _mesa_reference_array_object(ctx, &ctx->Array.DrawArrayObj, ctx->Array.ArrayObj);<br>
+<br>
if (exec->array.recalculate_inputs) {<br>
recalculate_input_bindings(ctx);<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
1.7.10.4<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>