Andrew Dunstan <and...@dunslane.net> writes:
> I have found the source of the problem I saw. dumputils.c:fmtId() uses a 
> static PQExpBuffer which it initialises the first time it's called. This 
> gets clobbered by simultaneous calls by Windows threads.

Ugh.  But that doesn't explain the original trouble report on Unixware.

> I could just make it auto and set it up on each call, but that could 
> result in a non-trivial memory leak ... it's probably called a great 
> many times. Or I could provide a parallel version where we pass in a 
> PQExpBuffer that we create, one per thread, and is used by anything 
> called by the parallel code. That seems like a bit of a potential 
> footgun, though.

I think we should try hard to keep this localized to fmtId(), rather
than changing the callers --- the latter would be a huge readability
hit.  Is there a reasonable way to have fmtId use thread-local storage
for its PQExpBuffer pointer on Windows?

                        regards, tom lane

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to