---
 src/compiler/nir/nir_validate.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index ef2e2b62783..f8327c0dd45 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -26,6 +26,7 @@
  */
 
 #include "nir.h"
+#include "c11/threads.h"
 #include <assert.h>
 
 /*
@@ -1169,11 +1170,18 @@ destroy_validate_state(validate_state *state)
    _mesa_hash_table_destroy(state->errors, NULL);
 }
 
+mtx_t fail_dump_mutex = _MTX_INITIALIZER_NP;
+
 static void
 dump_errors(validate_state *state, const char *when)
 {
    struct hash_table *errors = state->errors;
 
+   /* Lock around dumping so that we get clean dumps in a multi-threaded
+    * scenario
+    */
+   mtx_lock(&fail_dump_mutex);
+
    if (when) {
       fprintf(stderr, "NIR validation failed %s\n", when);
       fprintf(stderr, "%d errors:\n", _mesa_hash_table_num_entries(errors));
@@ -1192,6 +1200,8 @@ dump_errors(validate_state *state, const char *when)
       }
    }
 
+   mtx_unlock(&fail_dump_mutex);
+
    abort();
 }
 
-- 
2.20.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to