Re: Probable memory leak with ECPG and AIX
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Noah Misch <noah@leadboat.com>
Cc: Guillaume Lelarge <guillaume@lelarge.info>, Benoit Lobréau <benoit.lobreau@gmail.com>, PostgreSQL Developers <pgsql-hackers@postgresql.org>, "Dr. Michael Meskes" <michael.meskes@credativ.com>
Date: 2022-07-02T18:53:34Z
Lists: pgsql-hackers
Noah Misch <noah@leadboat.com> writes:
> I had expected to use pthread_once() for the newlocale() call, but there would
> be no useful way to report failure and try again later. Instead, I called
> newlocale() while ECPGconnect() holds connections_mutex. See log message and
> comments for details. I tested "./configure ac_cv_func_uselocale=no ..." and
> tested the scenario of newlocale() failing every time.
This looks solid to me. The only nit I can find to pick is that I'd
have added one more comment, along the lines of
diff --git a/src/interfaces/ecpg/ecpglib/connect.c b/src/interfaces/ecpg/ecpglib/connect.c
index 9f958b822c..96f99ae072 100644
--- a/src/interfaces/ecpg/ecpglib/connect.c
+++ b/src/interfaces/ecpg/ecpglib/connect.c
@@ -508,6 +508,11 @@ ECPGconnect(int lineno, int c, const char *name, const char *user, const char *p
#ifdef ENABLE_THREAD_SAFETY
pthread_mutex_lock(&connections_mutex);
#endif
+
+ /*
+ * ... but first, make certain we have created ecpg_clocale. Rely on
+ * holding connections_mutex to ensure this is done by only one thread.
+ */
#ifdef HAVE_USELOCALE
if (!ecpg_clocale)
{
I've marked it RFC.
regards, tom lane
Commits
-
Fix previous commit's ecpg_clocale for ppc Darwin.
- f5e4d64bb338 10.22 landed
- 1cad30e3ba82 11.17 landed
- a4240139fc76 12.12 landed
- 97b005f3fb1b 13.8 landed
- 8533eb181ae4 15.0 landed
- 463a841d7407 14.5 landed
- e2bc242833da 16.0 landed
-
ecpglib: call newlocale() once per process.
- d68b731a1504 11.17 landed
- 12b2a2369deb 10.22 landed
- b4d7e92bd535 13.8 landed
- 7a28f7cb09bf 15.0 landed
- 5e0b8f3f4f87 12.12 landed
- 5b94e2bd4d54 14.5 landed
- 5633836ef306 16.0 landed