aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndres Freund <andres@anarazel.de>2020-04-05 18:23:30 -0700
committerAndres Freund <andres@anarazel.de>2020-04-05 18:23:30 -0700
commitfc3f4453a2bc95549682e23600b22e658cb2d6d7 (patch)
tree18772ad598c4447815a1ece9594d1d248d2c5f2a
parentf946069e6827e729857b9f2db06bf27a1c0563ee (diff)
downloadpostgresql-fc3f4453a2bc95549682e23600b22e658cb2d6d7.tar.gz
postgresql-fc3f4453a2bc95549682e23600b22e658cb2d6d7.zip
Recompute stack base in forked postmaster children.
This is for the benefit of running postgres under the rr debugger. When using rr signal handlers running while a syscall is active use an alternative stack. As e.g. bgworkers are started from within signal handlers, the forked backend then has a different stack base than postmaster. Previously that subsequently lead to those processes triggering spurious "stack depth limit exceeded" errors. Discussion: https://postgr.es/m/20200327182217.ubrrl32lyfhxfwk5@alap3.anarazel.de
-rw-r--r--src/backend/postmaster/postmaster.c5
-rw-r--r--src/backend/utils/init/miscinit.c9
2 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 73d278f3b2c..0578e92ba9c 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -4901,11 +4901,6 @@ SubPostmasterMain(int argc, char *argv[])
ClosePostmasterPorts(strcmp(argv[1], "--forklog") == 0);
/*
- * Set reference point for stack-depth checking
- */
- set_stack_base();
-
- /*
* Set up memory area for GSS information. Mirrors the code in ConnCreate
* for the non-exec case.
*/
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index a7b7b12249d..6fe25c023a4 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -92,6 +92,15 @@ InitPostmasterChild(void)
{
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
+ /*
+ * Set reference point for stack-depth checking. We re-do that even in the
+ * !EXEC_BACKEND case, because there are some edge cases where processes
+ * are started with an alternative stack (e.g. starting bgworkers when
+ * running postgres using the rr debugger, as bgworkers are launched from
+ * signal handlers).
+ */
+ set_stack_base();
+
InitProcessGlobals();
/*