Skip to content

Commit fc3f445

Browse files
committed
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/[email protected]
1 parent f946069 commit fc3f445

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

src/backend/postmaster/postmaster.c

-5
Original file line numberDiff line numberDiff line change
@@ -4900,11 +4900,6 @@ SubPostmasterMain(int argc, char *argv[])
49004900
/* Close the postmaster's sockets (as soon as we know them) */
49014901
ClosePostmasterPorts(strcmp(argv[1], "--forklog") == 0);
49024902

4903-
/*
4904-
* Set reference point for stack-depth checking
4905-
*/
4906-
set_stack_base();
4907-
49084903
/*
49094904
* Set up memory area for GSS information. Mirrors the code in ConnCreate
49104905
* for the non-exec case.

src/backend/utils/init/miscinit.c

+9
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ InitPostmasterChild(void)
9292
{
9393
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
9494

95+
/*
96+
* Set reference point for stack-depth checking. We re-do that even in the
97+
* !EXEC_BACKEND case, because there are some edge cases where processes
98+
* are started with an alternative stack (e.g. starting bgworkers when
99+
* running postgres using the rr debugger, as bgworkers are launched from
100+
* signal handlers).
101+
*/
102+
set_stack_base();
103+
95104
InitProcessGlobals();
96105

97106
/*

0 commit comments

Comments
 (0)