pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Noah Misch <noah@leadboat.com>
Cc: Guillaume Lelarge <guillaume@lelarge.info>
Cc: Benoit Lobréau <benoit.lobreau@gmail.com>
Cc: PostgreSQL Developers <pgsql-hackers@postgresql.org>
Cc: Dr. Michael Meskes <michael.meskes@credativ.com>
Subject: Re: Probable memory leak with ECPG and AIX
Date: Sat, 02 Jul 2022 14:53:34 -0400
Message-ID: <964681.1656788014@sss.pgh.pa.us> (raw)
In-Reply-To: <20220418041645.GA1134228@rfd.leadboat.com>
References: <CAECtzeWMVW=b8=DJje_4F=OG9BeYLh-phLcCxZ-FBpii+O=SBQ@mail.gmail.com>
	<20211212073411.GA2218865@rfd.leadboat.com>
	<CAPE8EZ4ca2s5tDVHZzQ=iGh+rD8VX5r4Gk8zTTEeh9VaDOMnuQ@mail.gmail.com>
	<CAPE8EZ42eWAemjj58DO0WArCMDG2VYWut38aAGo9V8QH8ETqrg@mail.gmail.com>
	<20220101074055.GA54621@rfd.leadboat.com>
	<2865639.1641054902@sss.pgh.pa.us>
	<20220102000750.GB54621@rfd.leadboat.com>
	<20220418041645.GA1134228@rfd.leadboat.com>

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





view thread (20+ messages)  latest in thread

Message-ID: <964681.1656788014@sss.pgh.pa.us>
Permalink:  ../964681.1656788014@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/964681.1656788014@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: tgl@sss.pgh.pa.us, noah@leadboat.com, guillaume@lelarge.info, benoit.lobreau@gmail.com, michael.meskes@credativ.com
  Subject: Re: Probable memory leak with ECPG and AIX
  In-Reply-To: <964681.1656788014@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox