Re: [PATCH] Silence Valgrind about SelectConfigFiles()
Aleksander Alekseev <aleksander@tigerdata.com>
From: Aleksander Alekseev <aleksander@tigerdata.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Date: 2025-08-13T23:35:52Z
Lists: pgsql-hackers
Hi Tom,
> You didn't say what the test condition was, but from the patch
> I suppose it's a case where SelectConfigFiles is erroring out?
Steps to reproduce:
1. Uncomment USE_VALGRIND in src/include/pg_config_manual.h, then
rebuild and setup Postgres as usual
2. In the first terminal:
```
$ valgrind \
--leak-check=full \
--track-origins=yes \
--gen-suppressions=all \
--read-var-info=yes \
--log-file=/tmp/valgrind/%p.log \
--suppressions=src/tools/valgrind.supp \
--time-stamp=yes \
--trace-children=yes \
postgres -D /home/eax/pginstall/data \
2>&1 | tee /tmp/valgrind/postmaster.log
```
3. In the second terminal:
```
meson test -C build \
--setup running \
--suite regress-running \
--timeout-multiplier 0
pg_ctl -w -D /home/eax/pginstall/data stop
grep -r 'ERROR SUMMARY' /tmp/valgrind/ | grep -v 'SUMMARY: 0 errors'
```
> Kind of hard to get excited about preventing a leak in that path,
> since we're going to exit immediately.
It's not exciting at all but given the fact that this is the only
"definitely lost" error I got it's worth fixing IMO ("broken windows"
and all that). I should have also pointed out that SelectConfigFiles()
sometimes calls free(configdir) and sometimes doesn't, which is
inconsistent.
Sorry for little details in the first email - it's 2:30 AM in my time zone :)
Commits
-
Don't leak memory during failure exit from SelectConfigFiles().
- ed0736172170 19 (unreleased) landed