Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 1e50d59

Browse files
tglsfdcCommitfest Bot
authored and
Commitfest Bot
committed
Silence complaints about save_ps_display_args.
Valgrind seems not to consider the global "environ" variable as a valid root pointer; so when we allocate a new environment array, it claims that data is leaked. To fix that, keep our own statically-allocated copy of the pointer, similarly to the previous patch. Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/285483.1746756246@sss.pgh.pa.us
1 parent da5ff0b commit 1e50d59

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/backend/utils/misc/ps_status.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,17 @@ static void flush_ps_display(void);
100100
static int save_argc;
101101
static char **save_argv;
102102

103+
/*
104+
* Valgrind seems not to consider the global "environ" variable as a valid
105+
* root pointer; so when we allocate a new environment array, it claims that
106+
* data is leaked. To fix that, keep our own statically-allocated copy of the
107+
* pointer. (Oddly, this doesn't seem to be a problem for "argv".)
108+
*/
109+
#if defined(PS_USE_CLOBBER_ARGV) && defined(USE_VALGRIND)
110+
extern char **ps_status_new_environ;
111+
char **ps_status_new_environ;
112+
#endif
113+
103114

104115
/*
105116
* Call this early in startup to save the original argc/argv values.
@@ -206,6 +217,11 @@ save_ps_display_args(int argc, char **argv)
206217
}
207218
new_environ[i] = NULL;
208219
environ = new_environ;
220+
221+
/* See notes about Valgrind above. */
222+
#ifdef USE_VALGRIND
223+
ps_status_new_environ = new_environ;
224+
#endif
209225
}
210226

211227
/*

0 commit comments

Comments
 (0)