Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vs4vi-004ahG-0p for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 20:10:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vs4vf-005SHg-2z for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Feb 2026 20:10:48 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vs4vf-005SHU-0h for pgsql-hackers@lists.postgresql.org; Mon, 16 Feb 2026 20:10:47 +0000 Received: from fout-b6-smtp.messagingengine.com ([202.12.124.149]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vs4vc-000000014t8-3WAS for pgsql-hackers@postgresql.org; Mon, 16 Feb 2026 20:10:47 +0000 Received: from phl-compute-07.internal (phl-compute-07.internal [10.202.2.47]) by mailfout.stl.internal (Postfix) with ESMTP id 683E01D000DE; Mon, 16 Feb 2026 15:10:41 -0500 (EST) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-07.internal (MEProxy); Mon, 16 Feb 2026 15:10:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1771272641; x=1771359041; bh=EfEhqvJzxf //B9QJ2L/cSHIdgOJlUP+sU0oXuzLyi48=; b=cWSA5U3QEKB/3XIWCfeH5D7lbc W8zngt+gKipK20Gcs7D/qYAE33NTJ41f4MiDOsJp5S8WmpZ6kwXFYDRq9j/54uhY 3LnOx9BDlqcbHQQ/fmRb3pmLHulNZjm4iSSjKMxUMPiuqi3UK8+NCa9mDW1jNcph Vl9VoDMVtBqeZwPU5KjHWy8at6h6dsoLH3To9gXMOc/1VMbTXEoQPGeuKckO3mkT RekmZbEPwC7OABCWZGNgIJ7nkEGshbrZ9r/JtBb4ilitdhXNiMKqKGw426PUqsDm YLkQylpIpQPjY0D/+xlthxsNkLkCmtu/IrzkNaeDcqZxnPxg2cuj4Dn57FZw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1771272641; x=1771359041; bh=EfEhqvJzxf//B9QJ2L/cSHIdgOJlUP+sU0o XuzLyi48=; b=cj1yIblMCLosU9eJ2Ey2iCXK3IWok7nwJqkpLnAKsHxCee2uj1p m+rjYTbuy0p4JqisdtqNUzWs/0oH0uGBTEaFMROtvJnWu1B+yXGWYxXU00dKUUjp DsYJg/N2SXucH54q8/Ud/T90n/j4xMxWtum8UOEu/YpNCw18AscbImktuniWrEoJ Agcgy4nf0sVnquTrdxV1b0cLz+0M90l5FeFgIpjCNR6+nrgDKr9Vult/4Z9lxuSU omzgqHV+jFrfnhe+hZi3+mI6Bss0dQiYLlHhqCPuCaV6NQ8j7sxccWGenlGveAS+ ZDQyn/4XUh8JyuuSMbJ1TPg/yOmWVdpMLhA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvudejjeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggujgesthdtsfdttddtvdenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnhepfeffgfelvdffgedtveelgfdtgefghfdvkefggeetieevjeekteduleevjefh ueegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeehpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopegrnhhthhhonhhinhdrsghonhhnvghfohihsegurg htrgguohhghhhqrdgtohhmpdhrtghpthhtohepsggvrhhtrhgrnhguughrohhuvhhothdr phhgsehgmhgrihhlrdgtohhmpdhrtghpthhtohepthhhohhmrghsrdhmuhhnrhhosehgmh grihhlrdgtohhmpdhrtghpthhtohepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiidp rhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvshhqlhdrohhrgh X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 16 Feb 2026 15:10:40 -0500 (EST) Date: Mon, 16 Feb 2026 15:10:40 -0500 From: Andres Freund To: Anthonin Bonnefoy Cc: Bertrand Drouvot , Michael Paquier , Thomas Munro , PostgreSQL Hackers Subject: Re: Fix uninitialized xl_running_xacts padding Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-02-16 12:02:33 +0100, Anthonin Bonnefoy wrote: > I think that depends on the C standard used. With C99, there's no rule > for the padding bytes initialization. > With C11, in 6.7.9 Initialization of the standard: "the remainder of > the aggregate shall be initialized implicitly the same as objects that > have static storage duration", and with static storage will "every > member is initialized (recursively) according to these rules, and any > padding is initialized to zero bits". I don't think that rule applies for things like xl_running_xacts, as it does not have static storage duration. > So if I read this correctly, '{0}' will set padding bytes to 0 when > using C11. But given Postgres is using C99, that's not something we > can rely on? We use C11, but the guarantee doesn't help us, due to the static storage duration restriction. However, in C23, this has been fixed: 6.7.10 Initialization, point 11: If an object that has automatic storage duration is initialized with an empty initializer, its value is the same as the initialization of a static storage duration object. Otherwise, if an object that has automatic storage duration is not initialized explicitly, its representation is indeterminate. [...] This notably includes being able to initialize everything to default with {}. But C23 won't help us for a while :( > > > True about the initialization part, mostly I guess, still we tend to > > > worry about eliminating padding because these are wasted bytes in the > > > WAL records. For example, xlhp_freeze_plans has two bytes of padding, > > > that we eliminate while inserting its record by splitting the > > > FLEXIBLE_ARRAY_MEMBER part. > > > > But in the case of this thread it's in the middle of the struct, so I'm not > > sure the "wasted" bytes would be elminated, would it? > > Moving subxid_overflow before xids, wouldn't you have 3 bytes of > padding at the end of the struct for the whole struct alignment? Yes. I'm a bit doubtful the space wastage argument is strong for most of the record types with padding, for a lot of them the waste through the padding is such a small amount compared to the record type that it won't matter. I don't think it makes a whole lot of sense to tackle this specifically for xl_running_xacts. Until now we just accepted that WAL insertions can contain random padding. If we don't want that, we should go around and make sure that there is no padding (or padding is initialized) for *all* WAL records, document that as the rule, and remove the relevant valgrind suppressions. A lot of the WAL structs have holes. At least - xl_brin_update - xl_btree_mark_page_halfdead - xl_btree_unlink_page - xl_hash_vacuum_one_page - xl_heap_inplace - xl_heap_multi_insert - xl_heap_rewrite_mapping - xl_heap_truncate - xl_invalidations - xl_logical_message - xl_multixact_create - xl_running_xacts - xl_xact_prepare - xlhp_freeze_plan (not a toplevel type) - xlhp_freeze_plans (not a toplevel type) I didn't check how many WAL record have trailing padding that we don't avoid with offsetoff(structname, last_field) + sizeof(last_field_type) style hackery. Greetings, Andres Freund