diff options
| author | Tom Lane | 2019-01-22 04:18:58 +0000 |
|---|---|---|
| committer | Tom Lane | 2019-01-22 04:18:58 +0000 |
| commit | eb3e90cad1e48ce5ad55335514d639744a295b78 (patch) | |
| tree | c581e273b7d97ddb745358e9e3429c9f56c12213 /configure.in | |
| parent | 4aead13a751f86a9e143d3ee931171a11fd7bf7e (diff) | |
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
Diffstat (limited to 'configure.in')
| -rw-r--r-- | configure.in | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/configure.in b/configure.in index 86fbdff8d44..ecebc16dbcd 100644 --- a/configure.in +++ b/configure.in @@ -1503,7 +1503,32 @@ PGAC_FUNC_WCSTOMBS_L LIBS_including_readline="$LIBS" LIBS=`echo "$LIBS" | sed -e 's/-ledit//g' -e 's/-lreadline//g'` -AC_CHECK_FUNCS([cbrt dlopen fdatasync getifaddrs getpeerucred getrlimit mbstowcs_l memmove poll posix_fallocate pstat pthread_is_threaded_np readlink setproctitle setsid shm_open symlink sync_file_range towlower utime utimes wcstombs wcstombs_l]) +AC_CHECK_FUNCS(m4_normalize([ + cbrt + dlopen + fdatasync + getifaddrs + getpeerucred + getrlimit + mbstowcs_l + memmove + poll + posix_fallocate + pstat + pthread_is_threaded_np + readlink + setproctitle + setsid + shm_open + symlink + sync_file_range + towlower + uselocale + utime + utimes + wcstombs + wcstombs_l +])) AC_REPLACE_FUNCS(fseeko) case $host_os in @@ -1667,6 +1692,7 @@ fi # Win32 (really MinGW) support if test "$PORTNAME" = "win32"; then + AC_CHECK_FUNCS(_configthreadlocale) AC_REPLACE_FUNCS(gettimeofday) AC_LIBOBJ(dirmod) AC_LIBOBJ(kill) |
