Re: Small memory fixes for pg_createsubcriber
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Euler Taveira <euler@eulerto.com>,
"ranier.vf@gmail.com" <ranier.vf@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-02-25T12:39:28Z
Lists: pgsql-hackers
Hi, On 2025-02-12 19:08:31 -0500, Tom Lane wrote: > Michael Paquier <michael@paquier.xyz> writes: > > I have looked at bit at the uses of PQescapeLiteral() and > > PQescapeIdentifier() in the tree. On top of the one in pg_amcheck you > > are just pointing to, there is an inconsistency in pg_upgrade.c for > > set_locale_and_encoding() where datlocale_literal may be allocated > > with a pg_strdup() or a PQescapeLiteral() depending on the path. The > > code has been using PQfreemem() for the pg_strdup() allocation, which > > is logically incorrect. > > Yeah, I suspected there would be places like that. It just hasn't > mattered in practice up to now. (I have a vague recollection that > Windows used to be pickier about this, but evidently not in recent > years.) It's a question of compiler / link options. If you e.g. have a debug psql runtime linked against a non-debug libpq, the allocators for both will differ. Or if you link an application statically while a library is built for a shared C runtime. Or a few other such things. But when building in the BF / CI we'll not typically encounter this issue between libraries and binaries in our source tree, because they'll all be built the same. However, we have more recently hit this with external libraries we link to. While it's not recommended, we commonly build (in BF/CI) a debug postgres against production openssl, zstd etc. Which means they don't share allocators, file descriptors etc. Greetings, Andres Freund
Commits
-
pg_upgrade: Fix inconsistency in memory freeing
- 9ca2145b00fb 16.9 landed
- ee78823ff5f6 17.5 landed
- 2a083ab807db 18.0 landed
-
pg_amcheck: Fix inconsistency in memory freeing
- 35a591a0486f 14.18 landed
- ec741d48036a 15.13 landed
- 816149dc6bf9 16.9 landed
- f903d4da9276 17.5 landed
- 48e4ae9a0707 18.0 landed
-
Fix some inconsistencies with memory freeing in pg_createsubscriber
- ff6d9cfcb17e 17.4 landed
- 5b94e2753439 18.0 landed
-
Drop pre-existing subscriptions from the converted subscriber.
- 4867f8a555ce 18.0 cited