summaryrefslogtreecommitdiff
path: root/src/compiler
diff options
context:
space:
mode:
authorMartin Krastev <krastevm@vmware.com>2021-06-15 12:18:31 -0700
committerMarge Bot <eric+marge@anholt.net>2021-06-16 23:14:23 +0000
commiteb272f65715c21c38c0dc0f5a84f431851aa87d0 (patch)
tree57eda65713bce8c1d136f9eec0eabe2a9d65ae57 /src/compiler
parent4a407e0ad8801cc822666f41591094b2cbb2e826 (diff)
compiler/glsl: Use mutex lock while freeing up mem_ctx
builtin_builder::~builtin_builder() and builtin_builder::release() are running into race condition. This leads lightsmark to crash at the end because both calls ralloc_free which mutates the arguments state This patch fixes lightsmark2008 crash Fixes: e4da8b9c331cc3a ("mesa/compiler: rework tear down of builtin/types") Reviewed-by: Charmaine Lee <charmainel@vmware.com> Reviewed-by: Neha Bhende <bhenden@vmware.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Tested-by: Neha Bhende <bhenden@vmware.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11385>
Diffstat (limited to 'src/compiler')
-rw-r--r--src/compiler/glsl/builtin_functions.cpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/compiler/glsl/builtin_functions.cpp b/src/compiler/glsl/builtin_functions.cpp
index 6d700c14bec..9f3b526671e 100644
--- a/src/compiler/glsl/builtin_functions.cpp
+++ b/src/compiler/glsl/builtin_functions.cpp
@@ -90,6 +90,8 @@
using namespace ir_builder;
+static mtx_t builtins_lock = _MTX_INITIALIZER_NP;
+
/**
* Availability predicates:
* @{
@@ -1296,7 +1298,15 @@ builtin_builder::builtin_builder()
builtin_builder::~builtin_builder()
{
+ mtx_lock(&builtins_lock);
+
ralloc_free(mem_ctx);
+ mem_ctx = NULL;
+
+ ralloc_free(shader);
+ shader = NULL;
+
+ mtx_unlock(&builtins_lock);
}
ir_function_signature *
@@ -7753,7 +7763,6 @@ builtin_builder::_helper_invocation()
/* The singleton instance of builtin_builder. */
static builtin_builder builtins;
-static mtx_t builtins_lock = _MTX_INITIALIZER_NP;
static uint32_t builtin_users = 0;
/**