Re: Fix uninitialized xl_running_xacts padding
Heikki Linnakangas <hlinnaka@iki.fi>
From: Heikki Linnakangas <hlinnaka@iki.fi>
To: Alexander Kuzmenkov <akuzmenkov@tigerdata.com>
Cc: Andres Freund <andres@anarazel.de>,
Anthonin Bonnefoy <anthonin.bonnefoy@datadoghq.com>,
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>,
Michael Paquier <michael@paquier.xyz>, Thomas Munro
<thomas.munro@gmail.com>, PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Date: 2026-03-12T12:54:52Z
Lists: pgsql-hackers
Attachments
- 0001-Initialize-WAL-record-structs.patch (text/x-patch) patch 0001
- 0002-Avoid-padding-in-xl_multixact_create-WAL-record.patch (text/x-patch) patch 0002
- 0003-XXX-a-few-more-places-that-maybe-need-clearing.patch (text/x-patch) patch 0003
- 0004-Add-an-explicit-valgrind-check-in-XLogInsert-for-uni.patch (text/x-patch) patch 0004
On 11/03/2026 13:07, Alexander Kuzmenkov wrote: > On Wed, Mar 11, 2026 at 11:45 AM Alexander Kuzmenkov > <akuzmenkov@tigerdata.com> wrote: >> >> On Tue, Mar 10, 2026 at 11:09 PM Heikki Linnakangas <hlinnaka@iki.fi> wrote: >>> +1 for initializing all padding in WAL records. In fact I thought that >>> we already did that. (Except in this case, apparently) >> >> I found 42 exceptions like this. See the attached patch, it >> initializes some WAL records and removes the WAL-related Valgrind >> suppressions. The regression tests pass under Valgrind with these >> changes. > > I think I'm making some unneeded changes here though. For example in > ginxlogInsertListPage for a two-int struct with no padding. I'll need > to check them again one by one. I experimented with this a little more. Valgrind complained about one more place on 'master': the xl_multixact_create got padding, when MultiXactOffset was widened to 64 bits. That could be fixed by swapping the fields. Another thing I did to find possible initializations: I ran 'pahole bin/postgres' and search for all the "xl_*" structs with padding, and then looked at where they're initialized. Attached patch (0003) shows a few places that look suspicious to me. I don't think I caught all structs used in WAL records, though, like the ginxlogInsertListPage thing mentioned. I wish we could just mark all WAL record structs with pg_attribute_packed(). Unfortunately pg_attribute_packed() is not available on all compilers we support. - Heikki
Commits
-
Add test for single-page VACUUM of hash index on INSERT
- 1f7947a48d0c 19 (unreleased) landed