I sent the original in haste, and now I need to make some corrections... sigh.
> Subject: Fix for pg_stat_activity putting client hostaddr into appname field
Actually, it's the hostname appears in the appname field.
> I noticed when querying pg_stat_activity (in 10.1):
10.1 was where I first noticed the bug, but it's still present in master.
> I've tracked this down to bootstrap/pgstat.c.
Should be postmaster/pgstat.c.
> In the case of my query, the pointers for st_appname in the aux processes happen to point into the
BackendClientHostnameBuffersegment.
To be clear, I think this is a memory error. These rogue pointers
could do a lot more damage than merely pointing to the wrong strings.
> It's an extra 3 kB ...
A rough estimate, that was also wrong. 7 aux processes * (1024 bytes
activity + 64 for hostname + 64 for appname) = about 8 kB.
I do apologise for the confusion!
Edmund