mesa/st: release debug_output after destroying the context
authorPierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Tue, 7 Jul 2020 09:08:50 +0000 (11:08 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 15 Jul 2020 09:13:51 +0000 (09:13 +0000)
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3230
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2218
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5789>

src/mesa/state_tracker/st_context.c

index 3b1fb8628915d2e9e4f67a44dccf61da6a9e6b51..490e959d6da382f2aa53e448dffc052385dd3202 100644 (file)
@@ -29,6 +29,7 @@
 #include "main/accum.h"
 #include "main/api_exec.h"
 #include "main/context.h"
 #include "main/accum.h"
 #include "main/api_exec.h"
 #include "main/context.h"
+#include "main/debug_output.h"
 #include "main/glthread.h"
 #include "main/samplerobj.h"
 #include "main/shaderobj.h"
 #include "main/glthread.h"
 #include "main/samplerobj.h"
 #include "main/shaderobj.h"
@@ -1103,13 +1104,19 @@ st_destroy_context(struct st_context *st)
 
    st_destroy_program_variants(st);
 
 
    st_destroy_program_variants(st);
 
-   _mesa_free_context_data(ctx, true);
+   /* Do not release debug_output yet because it might be in use by other threads.
+    * These threads will be terminated by _mesa_free_context_data and
+    * st_destroy_context_priv.
+    */
+   _mesa_free_context_data(ctx, false);
 
    /* This will free the st_context too, so 'st' must not be accessed
     * afterwards. */
    st_destroy_context_priv(st, true);
    st = NULL;
 
 
    /* This will free the st_context too, so 'st' must not be accessed
     * afterwards. */
    st_destroy_context_priv(st, true);
    st = NULL;
 
+   _mesa_destroy_debug_output(ctx);
+
    free(ctx);
 
    if (save_ctx == ctx) {
    free(ctx);
 
    if (save_ctx == ctx) {