From fb80149e0517b33dd265ca5b1f559b0f60405a5a Mon Sep 17 00:00:00 2001
From: Tom Lane <tgl@sss.pgh.pa.us>
Date: Sun, 11 May 2025 12:52:32 -0400
Subject: [PATCH v1 02/11] Temporarily suppress some Valgrind complaints.

This isn't meant for commit, but it is useful to reduce the large
amount of leak-check noise generated by a couple of known problems:

Temporary buffers, as well as some other structures, are allocated in
a way that causes us not to hold any pointer to what Valgrind thinks
is the start of the chunk.  That causes "possible leak" reports.

PL/pgSQL and SQL-function parsing leak stuff into the long-lived
function cache context.  This isn't really a huge problem, since
the cruft will be recovered if we have to re-parse the function.
But it leads to a lot of complaints from Valgrind.

We need better answers for these things, but for the moment hide
them to allow sorting through other leakage problems.

Author: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/285483.1746756246@sss.pgh.pa.us
---
 src/tools/valgrind.supp | 42 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/src/tools/valgrind.supp b/src/tools/valgrind.supp
index 7ea464c8094..7d4fb0b2c1d 100644
--- a/src/tools/valgrind.supp
+++ b/src/tools/valgrind.supp
@@ -180,3 +180,45 @@
    Memcheck:Cond
    fun:PyObject_Realloc
 }
+
+# Suppress complaints about aligned allocations of temp buffers.
+# This ought to be fixed properly, instead.
+{
+   hide_temp_buffer_allocations
+   Memcheck:Leak
+   match-leak-kinds: possible
+   fun:MemoryContextAlloc
+   fun:GetLocalBufferStorage
+}
+
+# Suppress complaints about aligned allocations of other stuff.
+# This ought to be fixed properly, instead.
+{
+   hide_alignment_leakage
+   Memcheck:Leak
+   match-leak-kinds: possible
+   fun:MemoryContextAllocExtended
+   fun:MemoryContextAllocAligned
+}
+
+# Suppress complaints about stuff leaked by PL/pgSQL parsing.
+# This ought to be fixed properly, instead.
+{
+   hide_plpgsql_parsing_leaks
+   Memcheck:Leak
+   match-leak-kinds: definite,possible,indirect
+
+   ...
+   fun:plpgsql_compile_callback
+}
+
+# And likewise for stuff leaked by SQL-function parsing.
+# This ought to be fixed properly, instead.
+{
+   hide_sql_parsing_leaks
+   Memcheck:Leak
+   match-leak-kinds: definite,possible,indirect
+
+   ...
+   fun:sql_compile_callback
+}
-- 
2.43.5

