From f3c9ea9b8d3a266586817b3b0de0daef9d520e4e Mon Sep 17 00:00:00 2001 From: Patrick Lerda Date: Fri, 5 Jul 2024 15:43:36 +0200 Subject: [PATCH] st/pbo_compute: fix async->nir memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is an issue happening on radeonsi after the commit 6f8e6fb99cc2 "mesa/st: use compute pbo download for readpixels". This commit enables a new code path which has this memory leak. For instance, this issue is triggered on radeonsi with "piglit/bin/glsl-fs-raytrace-bug27060 -auto -fbo": Too many leaks! Only the first 5000 leaks encountered will be reported. Indirect leak of 327424 byte(s) in 5582 object(s) allocated from: #0 0x7fe27fa4d7ef in __interceptor_malloc (/usr/lib64/libasan.so.6+0xb17ef) #1 0x7fe2717fd4df in ralloc_size ../src/util/ralloc.c:118 #2 0x7fe272dbbae4 in calc_dom_children ../src/compiler/nir/nir_dominance.c:138 #3 0x7fe272dbbae4 in nir_calc_dominance_impl ../src/compiler/nir/nir_dominance.c:192 #4 0x7fe272b7f4a2 in nir_metadata_require ../src/compiler/nir/nir_metadata.c:40 #5 0x7fe272ba0d50 in nir_opt_cse_impl ../src/compiler/nir/nir_opt_cse.c:43 #6 0x7fe272ba0d50 in nir_opt_cse ../src/compiler/nir/nir_opt_cse.c:67 #7 0x7fe272686f83 in gl_nir_opts ../src/compiler/glsl/gl_nir_linker.c:92 #8 0x7fe271a31e69 in create_conversion_shader ../src/mesa/state_tracker/st_pbo_compute.c:701 #9 0x7fe271a353fa in create_conversion_shader_async ../src/mesa/state_tracker/st_pbo_compute.c:810 #10 0x7fe271806ea8 in util_queue_thread_func ../src/util/u_queue.c:309 #11 0x7fe27186379a in impl_thrd_routine ../src/c11/impl/threads_posix.c:67 #12 0x7fe27ea9a7c3 (/lib64/libc.so.6+0x867c3) ... SUMMARY: AddressSanitizer: 1384704 byte(s) leaked in 17291 allocation(s). Fixes: 5dab7673e10f ("mesa/st: add specialized pbo download shaders") Signed-off-by: Patrick Lerda Reviewed-by: Marek Olšák Part-of: --- src/mesa/state_tracker/st_pbo_compute.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/mesa/state_tracker/st_pbo_compute.c b/src/mesa/state_tracker/st_pbo_compute.c index dc63312597f..f06de85c238 100644 --- a/src/mesa/state_tracker/st_pbo_compute.c +++ b/src/mesa/state_tracker/st_pbo_compute.c @@ -1348,6 +1348,7 @@ st_pbo_compute_deinit(struct st_context *st) if (async->cs) st->pipe->delete_compute_state(st->pipe, async->cs); util_queue_fence_destroy(&async->fence); + ralloc_free(async->nir); ralloc_free(async->copy); set_foreach_remove(&async->specialized, se) { struct pbo_spec_async_data *spec = (void*)se->key;