Re: BUG #15312: Possible access to unintended variable in "postgres/src/backend/postmaster/pgstat.c" line 2698

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: petrum@gmail.com
Cc: pgsql-bugs@lists.postgresql.org
Date: 2018-08-07T18:45:22Z
Lists: pgsql-bugs
=?utf-8?q?PG_Bug_reporting_form?= <noreply@postgresql.org> writes:
> 	MemSet(BackendActivityBuffer, 0, size); //HERE

> Shouldn't BackendActivityBufferSize be accessed in the marked line instead
> of size? 

Yeah, I think you're right --- looks like a pretty obvious copy-and-paste
oversight.  It's probably harmless as long as
pgstat_track_activity_query_size is at least NAMEDATALEN, but it's
not good.

Thanks for reporting that!

			regards, tom lane


Commits

  1. Fix incorrect initialization of BackendActivityBuffer.

  2. Try to log current the query string when a backend crashes.