From a65eefc5aa4915351bddf835f0713ce84f7ec859 Mon Sep 17 00:00:00 2001
From: Ivan Kush <ivan.kush@tantorlabs.ru>
Date: Wed, 22 Jul 2026 10:15:00 +0300
Subject: [PATCH] Add LeakSanitizer suppression for pg_config

pg_config is a short-lived frontend binary and intentionally relies on
process termination to release its allocations.

Add an LSan suppression matching the binary name, and enable leak
detection for the address-sanitizer CI job.
---
 .github/workflows/pg-ci.yml | 5 +++--
 src/tools/ci/lsan.supp      | 3 +++
 2 files changed, 6 insertions(+), 2 deletions(-)
 create mode 100644 src/tools/ci/lsan.supp

diff --git a/.github/workflows/pg-ci.yml b/.github/workflows/pg-ci.yml
index a2629c8..66f5a95 100644
--- a/.github/workflows/pg-ci.yml
+++ b/.github/workflows/pg-ci.yml
@@ -464,9 +464,10 @@ jobs:
       # Configure sanitizer runtime behavior to be suitable for running tests:
       # disable_coredump=0, abort_on_error=1: for useful backtraces in case of crashes
       # print_stacktraces=1,verbosity=2, duh
-      # detect_leaks=0: too many uninteresting leak errors in short-lived binaries
+      # detect_leaks=1: report leaks except those listed in the suppression file
       UBSAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:verbosity=2
-      ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=0
+      ASAN_OPTIONS: print_stacktrace=1:disable_coredump=0:abort_on_error=1:detect_leaks=1
+      LSAN_OPTIONS: suppressions=${{ github.workspace }}/src/tools/ci/lsan.supp
 
     steps:
       # GitHub Actions does not make it easy to share some, but not all,
diff --git a/src/tools/ci/lsan.supp b/src/tools/ci/lsan.supp
new file mode 100644
index 0000000..063250d
--- /dev/null
+++ b/src/tools/ci/lsan.supp
@@ -0,0 +1,3 @@
+# pg_config is a short-lived frontend program.  Its allocations are released
+# by the operating system when the process exits.
+leak:pg_config
-- 
2.47.3

