Re: BUG #17280: global-buffer-overflow on select from pg_stat_slru - Mailing list pgsql-bugs

From Michael Paquier
Subject Re: BUG #17280: global-buffer-overflow on select from pg_stat_slru
Date
Msg-id YYyFawH87Sv3VZGi@paquier.xyz
Whole thread Raw
In response to Re: BUG #17280: global-buffer-overflow on select from pg_stat_slru  (Kyotaro Horiguchi <horikyota.ntt@gmail.com>)
Responses Re: BUG #17280: global-buffer-overflow on select from pg_stat_slru
List pgsql-bugs
On Thu, Nov 11, 2021 at 10:39:23AM +0900, Kyotaro Horiguchi wrote:
> The loop is designed not to directly rely on SRLU_NUM_ELEMENTS so if
> we honor that design, we would take the first or the third way. The
> first way is smallest but I prefer the third way as it is
> straightforward as such kind of loops.  The attached is that for the
> master.
>
> The code was introduced at 13 and the attached applies to the versions
> back to 13.

Or it would be easier for the reader to assign stat after checking for
the result of pgstat_slru_name(), no?  I am not much a fan of this
code style that uses a counter, FWIW, but at the same time
SLRU_NUM_ELEMENTS is local to pgstat.c, so..
--
Michael

Attachment

pgsql-bugs by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum
Next
From: Andres Freund
Date:
Subject: Re: BUG #17255: Server crashes in index_delete_sort_cmp() due to race condition with vacuum