Module: Mesa Branch: staging/20.0 Commit: 50781aaa1b95a07b5b5aeb23872b26c21e52151f URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=50781aaa1b95a07b5b5aeb23872b26c21e52151f
Author: Axel Davy <[email protected]> Date: Sun May 10 20:12:56 2020 +0200 gallium/util: Fix leak in the live shader cache When the nir backend is used, the create_shader call is supposed to release state->ir.nir. When the cache hits, create_shader is not called, thus state->ir.nir should be freed. There is nothing to be done for the TGSI case as the tokens release is done by the caller. This fixes a leak noticed in: https://gitlab.freedesktop.org/mesa/mesa/-/issues/2931 Fixes: 4bb919b0b8b4ed6f6a7049c3f8d294b74b50e198 Signed-off-by: Axel Davy <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4980> (cherry picked from commit 47bfc799da61aadd60ef9cc5c4bf0651c519cc77) --- .pick_status.json | 2 +- src/gallium/auxiliary/util/u_live_shader_cache.c | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index abd9f5b6a08..e35ba3eb7c8 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -220,7 +220,7 @@ "description": "gallium/util: Fix leak in the live shader cache", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "master_sha": null, "because_sha": "4bb919b0b8b4ed6f6a7049c3f8d294b74b50e198" }, diff --git a/src/gallium/auxiliary/util/u_live_shader_cache.c b/src/gallium/auxiliary/util/u_live_shader_cache.c index 9c59b5fd3cf..b24689537b1 100644 --- a/src/gallium/auxiliary/util/u_live_shader_cache.c +++ b/src/gallium/auxiliary/util/u_live_shader_cache.c @@ -125,8 +125,11 @@ util_live_shader_cache_get(struct pipe_context *ctx, simple_mtx_unlock(&cache->lock); /* Return if the shader already exists. */ - if (shader) + if (shader) { + if (state->type == PIPE_SHADER_IR_NIR) + ralloc_free(state->ir.nir); return shader; + } /* The cache mutex is unlocked to allow multiple create_shader * invocations to run simultaneously. _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
