From: Tom Lane <tgl@sss.pgh.pa.us>
To: exclusion@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows
Date: Sat, 24 Oct 2020 11:50:04 -0400
Message-ID: <367782.1603554604@sss.pgh.pa.us> (raw)
In-Reply-To: <16685-d6cd241872c101d3@postgresql.org>
References: <16685-d6cd241872c101d3@postgresql.org>
PG Bug reporting form <noreply@postgresql.org> writes:
> I found that the get_descriptors() function called in ECPGdeallocate_desc
> sometimes can return null.
> The following debugging code inserted into the ECPGallocate_desc:
> ...
> shows on a failure:
> TlsGetValue() returned null on iteration 209, error: 0, descriptor_key: 28,
> initial descriptor_key: 0.
> or
> TlsGetValue() returned null on iteration: 369, error: 0, descriptor_key: 28,
> initial descriptor_key: 0
Hm. I'm supposing that 0 isn't likely to be the correct TLS index,
and what this is showing us is that we got here before anyone had
done descriptor_key_init.
I'll bet that the correct fix is
static void
set_descriptors(struct descriptor *value)
{
+ pthread_once(&descriptor_once, descriptor_key_init);
pthread_setspecific(descriptor_key, value);
}
and that you could probably reproduce this on non-Windows, too,
if you tried hard (sticking a delay in get_descriptors might do it).
regards, tom lane
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-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows
In-Reply-To: <367782.1603554604@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