pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Melanie Plageman <melanieplageman@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Avoid overflow computing visibility map length
Date: Thu, 19 Nov 2026 22:22:18 +0000
Message-ID: <E1xUAWH-00000000RHf-1Ljs@gemulon.postgresql.org> (raw)

Avoid overflow computing visibility map length

Computing the number of visibility map blocks used addition-based
ceiling division on a BlockNumber.  For heap lengths near MaxBlockNumber
on 32-bit builds, the addition could overflow and produce a much smaller
visibility map length, potentially zero.

Use quotient and remainder instead so the calculation cannot overflow.

Reported-by: Melanie Plageman <melanieplageman@gmail.com>
Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: shihao zhong <zhong950419@gmail.com>
Backpatch-through: 17

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/1b51ce7c9ded8d52ee0c5ba50be24f89536b262b

Modified Files
--------------
src/backend/access/heap/visibilitymap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)



view thread (4+ messages)

Message-ID: <E1xUAWH-00000000RHf-1Ljs@gemulon.postgresql.org>
Permalink:  ../E1xUAWH-00000000RHf-1Ljs@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xUAWH-00000000RHf-1Ljs@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: melanieplageman@gmail.com
  Subject: Re: pgsql: Avoid overflow computing visibility map length
  In-Reply-To: <E1xUAWH-00000000RHf-1Ljs@gemulon.postgresql.org>
  References: <E1xUAWH-00000000RHf-1Ljs@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox