From 82b554edd8113075e7c122062c508256d65c5c9d Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Fri, 17 Feb 2023 20:47:29 +0100 Subject: [PATCH] r600: fix shader blob memory leak Fixes: 5b205ef41307406983ffac829ae423d08f7527bc r600: Store nir shaders serialized to save memory Direct leak of 4096 byte(s) in 1 object(s) allocated from: #0 0x7faf89c3bb48 in __interceptor_realloc (/usr/lib64/libasan.so.6+0xb1b48) #1 0x7faf7be5981d in grow_to_fit ../src/util/blob.c:67 #2 0x7faf7be5a538 in grow_to_fit ../src/util/blob.c:49 #3 0x7faf7be5a538 in blob_reserve_bytes ../src/util/blob.c:177 #4 0x7faf7be5a538 in blob_reserve_uint32 ../src/util/blob.c:190 #5 0x7faf7d248a8c in nir_serialize ../src/compiler/nir/nir_serialize.c:2109 #6 0x7faf7df4fdbb in r600_pipe_shader_create ../src/gallium/drivers/r600/r600_shader.c:401 Signed-off-by: Patrick Lerda Reviewed-by: Gert Wollny Part-of: (cherry picked from commit 9b4eb7390790fb8c6d3033d42fbb9f63c3ea5c00) --- .pick_status.json | 2 +- src/gallium/drivers/r600/r600_shader.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 4facd644936d..cc6724ba5403 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -139,7 +139,7 @@ "description": "r600: fix shader blob memory leak", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "5b205ef41307406983ffac829ae423d08f7527bc" }, diff --git a/src/gallium/drivers/r600/r600_shader.c b/src/gallium/drivers/r600/r600_shader.c index dd6186b1409f..ceec7c747af8 100644 --- a/src/gallium/drivers/r600/r600_shader.c +++ b/src/gallium/drivers/r600/r600_shader.c @@ -402,6 +402,7 @@ int r600_pipe_shader_create(struct pipe_context *ctx, sel->nir_blob = malloc(blob.size); memcpy(sel->nir_blob, blob.data, blob.size); sel->nir_blob_size = blob.size; + blob_finish(&blob); } ralloc_free(sel->nir); sel->nir = NULL;