From 1a366d51effd0e9f3301d68c2d3dce09c8c43d1f Mon Sep 17 00:00:00 2001 From: Noah Misch Date: Wed, 7 Jan 2015 22:35:44 -0500 Subject: On Darwin, detect and report a multithreaded postmaster. Darwin --enable-nls builds use a substitute setlocale() that may start a thread. Buildfarm member orangutan experienced BackendList corruption on account of different postmaster threads executing signal handlers simultaneously. Furthermore, a multithreaded postmaster risks undefined behavior from sigprocmask() and fork(). Emit LOG messages about the problem and its workaround. Back-patch to 9.0 (all supported versions). --- src/port/exec.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/port/exec.c') diff --git a/src/port/exec.c b/src/port/exec.c index 8ce7c618ffc..077ac58b2b2 100644 --- a/src/port/exec.c +++ b/src/port/exec.c @@ -556,8 +556,20 @@ set_pglocale_pgservice(const char *argv0, const char *app) /* don't set LC_ALL in the backend */ if (strcmp(app, PG_TEXTDOMAIN("postgres")) != 0) + { setlocale(LC_ALL, ""); + /* + * One could make a case for reproducing here PostmasterMain()'s test + * for whether the process is multithreaded. Unlike the postmaster, + * no frontend program calls sigprocmask() or otherwise provides for + * mutual exclusion between signal handlers. While frontends using + * fork(), if multithreaded, are formally exposed to undefined + * behavior, we have not witnessed a concrete bug. Therefore, + * complaining about multithreading here may be mere pedantry. + */ + } + if (find_my_exec(argv0, my_exec_path) < 0) return; -- cgit v1.2.3