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-14T11:09:35Z
Lists: pgsql-hackers
Attachments
- trick.txt (text/plain)
- v2-0001-Fix-memory-leaks-in-SelectConfigFiles.patch (text/x-patch) patch v2-0001
Hi Tom, > Yeah, I noticed that too, and it does offend my inner neatnik. > > Instead of what you did, I'd be inclined to add > > free(configdir); > > return true; > + > +fail: > + free(configdir); > + > + return false; > } > > and then s/return false/goto fail/ throughout, so as to avoid > duplicating the free() calls. It's a minor point as things stand, > but if more cleanup gets added to the function I think it'd be > easier to maintain this way. Makes sense. Here is the corrected patch v2. > Huh ... don't quite see where in that recipe we'd reach a > SelectConfigFiles error exit. How exactly we reach this code patch is a good question. I tried to understand the exact conditions by using my steps to reproduce and an ancient debugging technique with sleep(), elog() and `watch` - see trick.txt. Unfortunately I was not able to reproduce it again nor under Valgrind nor without it. I guess it means that either I did something differently before or the right conditions are met under rare circumstances.
Commits
-
Don't leak memory during failure exit from SelectConfigFiles().
- ed0736172170 19 (unreleased) landed