Mesa (main): pan/bi,pan/mdg: Fix memory leak of hash tables

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 16 14:35:20 UTC 2021


Module: Mesa
Branch: main
Commit: a9ab168e16e04dfe3c26c3cf7992e6392ef6877e
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a9ab168e16e04dfe3c26c3cf7992e6392ef6877e

Author: Icecream95 <ixn at disroot.org>
Date:   Sat Aug 14 23:04:43 2021 +1200

pan/bi,pan/mdg: Fix memory leak of hash tables

Despite being created with a ralloc context, some memory is still
leaked when not manually destroying hash tables.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12376>

---

 src/panfrost/bifrost/bifrost_compile.c | 2 ++
 src/panfrost/midgard/midgard_compile.c | 3 +++
 2 files changed, 5 insertions(+)

diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index fca20b34096..226543cadb4 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -3624,6 +3624,7 @@ bifrost_compile_shader_nir(nir_shader *nir,
                                 bifrost_nir_lower_store_component,
                                 nir_metadata_block_index |
                                 nir_metadata_dominance, stores);
+                _mesa_hash_table_u64_destroy(stores);
         }
 
         NIR_PASS_V(nir, nir_lower_ssbo);
@@ -3764,5 +3765,6 @@ bifrost_compile_shader_nir(nir_shader *nir,
                 bi_print_stats(ctx, binary->size, stderr);
         }
 
+        _mesa_hash_table_u64_destroy(ctx->sysval_to_id);
         ralloc_free(ctx);
 }
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 609db5086c3..5e6b6e0c442 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -3282,5 +3282,8 @@ midgard_compile_shader_nir(nir_shader *nir,
                         ctx->spills, ctx->fills);
         }
 
+        _mesa_hash_table_u64_destroy(ctx->ssa_constants);
+        _mesa_hash_table_u64_destroy(ctx->sysval_to_id);
+
         ralloc_free(ctx);
 }



More information about the mesa-commit mailing list