Re: Thread-unsafe coding in ecpg
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew.dunstan@2ndquadrant.com>
Cc: "Joshua D. Drake" <jd@commandprompt.com>,
Andres Freund <andres@anarazel.de>,
"Tsunakawa,
Takayuki" <tsunakawa.takay@jp.fujitsu.com>,
Michael Meskes <meskes@postgresql.org>,
"pgsql-hackers@lists.postgresql.org"
<pgsql-hackers@lists.postgresql.org>
Date: 2019-01-24T03:10:04Z
Lists: pgsql-hackers
Andrew Dunstan <andrew.dunstan@2ndquadrant.com> writes:
> On 1/23/19 6:01 PM, Tom Lane wrote:
>> Perhaps there's some sort of setup that MinGW's version needs that
>> we're not doing?
> This seems to suggest something worse: https://reviews.llvm.org/D40181
> Not sure I fully understand what's happening here, though.
Me either, but I noted a couple of interesting extracts from that page:
Normal mingw that uses msvcrt.dll doesn't have per-thread locales so
it won't really work in any case (but I think it does define some sort
of dummy functions that at least will allow it to build). Nowadays,
mingw can be built to target ucrtbase.dll as well though, and there it
should be possible to make it work just like for MSVC although it
might need some patches.
... Looked into MinGW-w64 sources and this is indeed the
case. _configthreadlocale will return -1 and will not do anything.
This suggests that, rather than throwing up our hands if the initial
_configthreadlocale call returns -1, we should act as though the function
doesn't exist, and just soldier on the same as before. The code in there
assumes that -1 is a can't-happen case and doesn't try to recover,
but apparently that's over-optimistic.
regards, tom lane
Commits
-
Remove _configthreadlocale() calls in ecpg test suite.
- e3565fd61cee 12.0 landed
-
Remove infinite-loop hazards in ecpg test suite.
- d5a1fde39726 12.0 landed
- fbf5395cb1ea 9.5.16 landed
- 6d6333745b11 9.4.21 landed
- adc2553b7069 9.6.12 landed
- 5b5cb3b0eb31 10.7 landed
- 28868f77b6cb 11.2 landed
-
Blind attempt to fix _configthreadlocale() failures on MinGW.
- 773f594408b9 9.4.21 landed
- 7ac0e71aa623 9.5.16 landed
- 1d334ab6e0b5 9.6.12 landed
- dd815a94ccf5 10.7 landed
- b620cf2d4762 11.2 landed
- 2cf91ccb73ce 12.0 landed
-
Avoid thread-safety problem in ecpglib.
- f305e8457d1e 11.2 landed
- eb3e90cad1e4 9.6.12 landed
- c9ff6cbfc472 9.4.21 landed
- 844d91fd6496 9.5.16 landed
- 6106f9dd71ff 10.7 landed
- 8eb4a9312c95 12.0 landed
-
Second try at fixing ecpglib thread-safety problem.
- ee27584c4a40 12.0 landed