agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Álvaro Herrera <alvherre@kurilemu.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: pg_surgery: Fix infinite loop on large TID arrays
Date: Tue, 04 Aug 2026 09:47:37 +0000
Message-ID: <E1wrBkH-000000009Cm-3HHX@gemulon.postgresql.org> (raw)

pg_surgery: Fix infinite loop on large TID arrays

heap_force_common() tracked the current position in the caller-supplied
tid[] using OffsetNumber, which is only 16 bits wide, so when the array
held more than 65535 entries, the updated index wrapped around and the
outer loop never reached the exit condition.  A SQL call with a
sufficiently large TID array would then run until interrupted.

Fix by tracking the tid[] position using int instead of OffsetNumber.
A regress case based on the report is included.

Author: Andrey Rachitskiy <pl0h0yp1@gmail.com>
Reviewed-by: Andrey Borodin <x4mmm@yandex-team.ru>
Reported-by: Yuelin Wang <1217816127@qq.com>
Backpatch-through: 14
Bug: #19607
Discussion: https://postgr.es/m/19607-2f256a66481c514b@postgresql.org

Branch
------
REL_18_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/19f0391df48202e2c6ac2e30a4c1c284aab5681b

Modified Files
--------------
contrib/pg_surgery/expected/heap_surgery.out | 17 +++++++++++++++++
contrib/pg_surgery/heap_surgery.c            |  6 +++---
contrib/pg_surgery/sql/heap_surgery.sql      |  8 ++++++++
3 files changed, 28 insertions(+), 3 deletions(-)



view thread (7+ messages)  latest in thread

Message-ID: <E1wrBkH-000000009Cm-3HHX@gemulon.postgresql.org>
Permalink:  ../E1wrBkH-000000009Cm-3HHX@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wrBkH-000000009Cm-3HHX@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 using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: alvherre@kurilemu.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: pg_surgery: Fix infinite loop on large TID arrays
  In-Reply-To: <E1wrBkH-000000009Cm-3HHX@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 agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox