pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Fix ancient bug in ecpg's pthread_once() emulation for Windows.
Date: Sat, 24 Oct 2020 17:13:34 +0000
Message-ID: <E1kWN6k-0002Np-Bm@gemulon.postgresql.org> (raw)

Fix ancient bug in ecpg's pthread_once() emulation for Windows.

We must not set the "done" flag until after we've executed the
initialization function.  Otherwise, other threads can fall through
the initial unlocked test before initialization is really complete.

This has been seen to cause rare failures of ecpg's thread/descriptor
test, and it could presumably cause other sorts of misbehavior in
threaded ECPG-using applications, since ecpglib relies on
pthread_once() in several places.

Diagnosis and patch by me, based on investigation by Alexander Lakhin.
Back-patch to all supported branches (the bug dates to 2007).

Discussion: https://postgr.es/m/16685-d6cd241872c101d3@postgresql.org

Branch
------
REL9_6_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/379c43bdad1d18786b87f38e8761f61a478b5875

Modified Files
--------------
src/interfaces/ecpg/ecpglib/misc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1kWN6k-0002Np-Bm@gemulon.postgresql.org>
Permalink:  ../E1kWN6k-0002Np-Bm@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1kWN6k-0002Np-Bm@gemulon.postgresql.org

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Fix ancient bug in ecpg's pthread_once() emulation for Windows.
  In-Reply-To: <E1kWN6k-0002Np-Bm@gemulon.postgresql.org>
  References: <E1kWN6k-0002Np-Bm@gemulon.postgresql.org>

* 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