Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: exclusion(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #16685: The ecpg thread/descriptor test fails sometimes on Windows
Date: 2020-10-24 15:50:04
Message-ID: 367782.1603554604@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PG Bug reporting form <noreply(at)postgresql(dot)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

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrey Borodin 2020-10-24 16:40:35 Re: BUG #16329: Valgrind detects an invalid read when building a gist index with buffering
Previous Message PG Bug reporting form 2020-10-24 14:35:31 BUG #16686: GCC C++ depends on libintl for some STL, even if PostgreSQL was not build with NLS support