| From: | Antonin Houska <ah(at)cybertec(dot)at> |
|---|---|
| To: | shihao zhong <zhong950419(at)gmail(dot)com> |
| Cc: | alvherre(at)kurilemu(dot)de, pgsql-hackers(at)lists(dot)postgresql(dot)org |
| Subject: | Re: REPACK enhancements |
| Date: | 2026-09-16 16:59:09 |
| Message-ID: | 224072.1789577949@localhost |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
shihao zhong <zhong950419(at)gmail(dot)com> wrote:
> 0001: in heap_insert_for_repack(), the reform slot borrows the source
> tuple's by-ref data (ExecForceStoreHeapTuple with shouldFree=false), but
> 'tuple' is freed before the insert reads from it -- a use-after-free if
> ExecFetchSlotHeapTuple(src) returns shouldFree=true. Latent today (the copy
> paths pass buffer/heaptuple slots), but the "nothing should depend on it
> now" comment is wrong. Suggest freeing after the insert; that also drops the
> slot-type assumption.
Since 'reform' slot is assumed to be "virtual", a new copy should be created
for the insert:
table_tuple_insert()
-> heapam_tuple_insert()
-> ExecFetchSlotHeapTuple(slot, materialize=true, ...)
('tuple' points to something that actually should not need freeing - added a
new assertion and comment.)
> Also, could you register this in the open commitfest so cfbot tracks it?
It's registered in the current CF. I think the "needs rebase" status is the
problem. Rebased version attached here.
> Testing 0004 now, will post new finding in following emails
Thanks!
--
Antonin Houska
Web: https://www.cybertec-postgresql.com
| Attachment | Content-Type | Size |
|---|---|---|
| v03-0001-Use-tuple-slot-to-pass-tuples-for-rewriting.patch | text/x-diff | 11.5 KB |
| v03-0002-Move-functions-to-repack.c.patch | text/x-diff | 8.4 KB |
| v03-0003-Introduce-RepackDest-structure.patch | text/x-diff | 18.8 KB |
| v03-0004-Use-multiple-snapshots-to-copy-the-data.patch | text/plain | 112.3 KB |
| v03-0005-Simplify-the-way-restrictions-are-imposed-on-index-f.patch | text/x-diff | 21.8 KB |
| v03-0006-Use-separate-transactions-for-catalog-changes.patch | text/x-diff | 42.4 KB |
| v03-0007-Decouple-updating-of-freezing-information-from-swap_.patch | text/x-diff | 8.1 KB |
| v03-0008-Make-REPACK-CONCURRENTLY-MVCC-safe.patch | text/plain | 115.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alberto Piai | 2026-09-16 17:02:05 | Re: Adding a stored generated column without long-lived locks |
| Previous Message | vignesh C | 2026-09-16 16:57:29 | Re: Distinguish publication exclusions in object addresses |