pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Avoid thread-safety problem in ecpglib. 6+ messages / 1 participants [nested] [flat]
* pgsql: Avoid thread-safety problem in ecpglib. @ 2019-01-21 17:07 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-01-21 17:07 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid thread-safety problem in ecpglib. ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. This should get back-patched, but let's see what the buildfarm thinks of it first. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/8eb4a9312c95be56cdb31f5411eddc2cb2ba89be Modified Files -------------- configure | 2 +- configure.in | 1 + src/include/pg_config.h.in | 3 ++ src/include/pg_config.h.win32 | 3 ++ src/interfaces/ecpg/ecpglib/descriptor.c | 37 +++++++++++++++++++----- src/interfaces/ecpg/ecpglib/ecpglib_extern.h | 11 ++++++++ src/interfaces/ecpg/ecpglib/execute.c | 42 +++++++++++++++++++++++++++- 7 files changed, 90 insertions(+), 9 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Avoid thread-safety problem in ecpglib. @ 2019-01-22 04:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-01-22 04:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid thread-safety problem in ecpglib. ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. (Subsequent buildfarm results show that recent NetBSD versions still lack uselocale(), but it's not a big problem because they also do not support non-"C" settings for LC_NUMERIC.) Back-patch of commits 8eb4a9312 and ee27584c4. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/f305e8457d1e19eb4e6f4e16f42061ebaf7cb509 Modified Files -------------- configure | 13 +++++++++- configure.in | 27 +++++++++++++++++++- src/include/pg_config.h.in | 6 +++++ src/include/pg_config.h.win32 | 6 +++++ src/interfaces/ecpg/ecpglib/descriptor.c | 37 ++++++++++++++++++++++------ src/interfaces/ecpg/ecpglib/execute.c | 42 +++++++++++++++++++++++++++++++- src/interfaces/ecpg/ecpglib/extern.h | 11 +++++++++ 7 files changed, 132 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Avoid thread-safety problem in ecpglib. @ 2019-01-22 04:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-01-22 04:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid thread-safety problem in ecpglib. ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. (Subsequent buildfarm results show that recent NetBSD versions still lack uselocale(), but it's not a big problem because they also do not support non-"C" settings for LC_NUMERIC.) Back-patch of commits 8eb4a9312 and ee27584c4. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us Branch ------ REL_10_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/6106f9dd71ff5f80fdaa41aa0e39f550967e2040 Modified Files -------------- configure | 13 +++++++++- configure.in | 29 +++++++++++++++++++++- src/include/pg_config.h.in | 6 +++++ src/include/pg_config.h.win32 | 6 +++++ src/interfaces/ecpg/ecpglib/descriptor.c | 37 ++++++++++++++++++++++------ src/interfaces/ecpg/ecpglib/execute.c | 42 +++++++++++++++++++++++++++++++- src/interfaces/ecpg/ecpglib/extern.h | 11 +++++++++ 7 files changed, 134 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Avoid thread-safety problem in ecpglib. @ 2019-01-22 04:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-01-22 04:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid thread-safety problem in ecpglib. ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. (Subsequent buildfarm results show that recent NetBSD versions still lack uselocale(), but it's not a big problem because they also do not support non-"C" settings for LC_NUMERIC.) Back-patch of commits 8eb4a9312 and ee27584c4. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us Branch ------ REL9_6_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/eb3e90cad1e48ce5ad55335514d639744a295b78 Modified Files -------------- configure | 13 +++++++++- configure.in | 28 ++++++++++++++++++++- src/include/pg_config.h.in | 6 +++++ src/include/pg_config.h.win32 | 6 +++++ src/interfaces/ecpg/ecpglib/descriptor.c | 37 ++++++++++++++++++++++------ src/interfaces/ecpg/ecpglib/execute.c | 42 +++++++++++++++++++++++++++++++- src/interfaces/ecpg/ecpglib/extern.h | 11 +++++++++ 7 files changed, 133 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Avoid thread-safety problem in ecpglib. @ 2019-01-22 04:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-01-22 04:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid thread-safety problem in ecpglib. ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. (Subsequent buildfarm results show that recent NetBSD versions still lack uselocale(), but it's not a big problem because they also do not support non-"C" settings for LC_NUMERIC.) Back-patch of commits 8eb4a9312 and ee27584c4. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us Branch ------ REL9_5_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/844d91fd64961e02a5a4034badcd8f8caef85b4a Modified Files -------------- configure | 13 +++++++++- configure.in | 29 +++++++++++++++++++++- src/include/pg_config.h.in | 6 +++++ src/include/pg_config.h.win32 | 6 +++++ src/interfaces/ecpg/ecpglib/descriptor.c | 37 ++++++++++++++++++++++------ src/interfaces/ecpg/ecpglib/execute.c | 42 +++++++++++++++++++++++++++++++- src/interfaces/ecpg/ecpglib/extern.h | 11 +++++++++ 7 files changed, 134 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
* pgsql: Avoid thread-safety problem in ecpglib. @ 2019-01-22 04:19 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 6+ messages in thread From: Tom Lane @ 2019-01-22 04:19 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org Avoid thread-safety problem in ecpglib. ecpglib attempts to force the LC_NUMERIC locale to "C" while reading server output, to avoid problems with strtod() and related functions. Historically it's just issued setlocale() calls to do that, but that has major problems if we're in a threaded application. setlocale() itself is not required by POSIX to be thread-safe (and indeed is not, on recent OpenBSD). Moreover, its effects are process-wide, so that we could cause unexpected results in other threads, or another thread could change our setting. On platforms having uselocale(), which is required by POSIX:2008, we can avoid these problems by using uselocale() instead. Windows goes its own way as usual, but we can make it safe by using _configthreadlocale(). Platforms having neither continue to use the old code, but that should be pretty much nobody among current systems. (Subsequent buildfarm results show that recent NetBSD versions still lack uselocale(), but it's not a big problem because they also do not support non-"C" settings for LC_NUMERIC.) Back-patch of commits 8eb4a9312 and ee27584c4. Michael Meskes and Tom Lane; thanks also to Takayuki Tsunakawa. Discussion: https://postgr.es/m/31420.1547783697@sss.pgh.pa.us Branch ------ REL9_4_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/c9ff6cbfc472bb2a0db79c141d6da0a51825b066 Modified Files -------------- configure | 13 +++++++++- configure.in | 29 +++++++++++++++++++++- src/include/pg_config.h.in | 6 +++++ src/include/pg_config.h.win32 | 6 +++++ src/interfaces/ecpg/ecpglib/descriptor.c | 37 ++++++++++++++++++++++------ src/interfaces/ecpg/ecpglib/execute.c | 42 +++++++++++++++++++++++++++++++- src/interfaces/ecpg/ecpglib/extern.h | 11 +++++++++ 7 files changed, 134 insertions(+), 10 deletions(-) ^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2019-01-22 04:19 UTC | newest] Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2019-01-21 17:07 pgsql: Avoid thread-safety problem in ecpglib. Tom Lane <tgl@sss.pgh.pa.us> 2019-01-22 04:19 pgsql: Avoid thread-safety problem in ecpglib. Tom Lane <tgl@sss.pgh.pa.us> 2019-01-22 04:19 pgsql: Avoid thread-safety problem in ecpglib. Tom Lane <tgl@sss.pgh.pa.us> 2019-01-22 04:19 pgsql: Avoid thread-safety problem in ecpglib. Tom Lane <tgl@sss.pgh.pa.us> 2019-01-22 04:19 pgsql: Avoid thread-safety problem in ecpglib. Tom Lane <tgl@sss.pgh.pa.us> 2019-01-22 04:19 pgsql: Avoid thread-safety problem in ecpglib. Tom Lane <tgl@sss.pgh.pa.us>
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