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.98.2) (envelope-from ) id 1xR5j2-00000000fn7-2dXL for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 10:38:44 +0000 Received: from localhost ([127.0.0.1]:44518 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR5iz-0000000AE0t-1ZrE for pgsql-bugs@arkaria.postgresql.org; Wed, 11 Nov 2026 10:38:41 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:50304) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR1Cj-00000008sKq-2SMM for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:49:05 +0000 Received: from mahout.postgresql.org ([2001:4800:3e1:1::227]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR1Ci-00000000JvA-3gPT for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:49:05 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=postgresql.org; s=20171124; h=Message-ID:Date:Reply-To:Cc:From:To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:Sender:Content-ID: Content-Description:In-Reply-To:References; bh=/fHAJPWN95JxSGQjztw0CWGFcX7MIz3/OjcuF7Q3HZk=; b=dTSuwQ4p+A2mPxPYPwQZB2H521 Cp385EKd+URaCf9Bt5LKmqDNsaXPvoutPrOOoV+UybgMJkU4irF4ajOct4hL5EJbMJVXUwpaHi+P5 GLZGJ4iJwvOTm3+ZmbrKp4mR83rjiWrTIFGD4cZRTNBXoCpgGJqrHvs/ma4ob47g/2K+awBkDBhix 7TTJCtyBepwC5oEpdeMcU+8CHY5l0IEFID4F3zpuCqflGQvjWuN81FFfvdJ+Y3bu1CRDapS7fB6Mw 93XTISD438Wz0XE8tMi8Sw7as1kDqVyu7baYEFq8XIUCEcSQ718qIBML+/oDoEezUv/qAG1yQ8H3B Kgsn49cQ==; Received: from wrigleys.postgresql.org ([2a02:16a8:dc51::60]) by mahout.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xR1Ci-00000000tAk-053U for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:49:04 +0000 Received: from localhost ([127.0.0.1] helo=wrigleys.postgresql.org) by wrigleys.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xR1Ch-00000002JQg-1756 for pgsql-bugs@lists.postgresql.org; Wed, 11 Nov 2026 05:49:03 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes To: pgsql-bugs@lists.postgresql.org From: PG Bug reporting form Cc: 1548140642@qq.com Reply-To: 1548140642@qq.com, pgsql-bugs@lists.postgresql.org Date: Wed, 11 Nov 2026 05:48:24 +0000 Message-ID: <19868-5efb930ace5bd191@postgresql.org> X-Auto-Response-Suppress: All Auto-Submitted: auto-generated List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk The following bug has been logged on the website: Bug reference: 19868 Logged by: Milo Email address: 1548140642@qq.com PostgreSQL version: 18.6 Operating system: Linux/amd64 Description: =20 When pg_resetwal -n reads a damaged pg_control whose uint32 xlog_seg_size field contains 4294967295, its invalid-WAL-segment-size warning prints "-1 bytes". The diagnostic should preserve the unsigned field value and print "4294967295 bytes". How to repeat: On the tested PostgreSQL 18 x86-64 build, save the following as reproducer.sh: ```sh #!/bin/sh set -eu d=3D$(mktemp -d) trap 'rm -rf "$d"' EXIT mkdir -p "$d/global" "$d/pg_wal" cp "$PGDATA/global/pg_control" "$d/global/pg_control" printf '18\n' > "$d/PG_VERSION" printf '\377\377\377\377' | dd of=3D"$d/global/pg_control" bs=3D1 seek=3D228 conv=3Dnotrunc 2>/dev/nu= ll /usr/lib/postgresql/18/bin/pg_resetwal -n -D "$d" 2>&1 || true ``` Run it with PGDATA naming a PostgreSQL 18 data directory: ```sh sh reproducer.sh ``` The script modifies only the isolated copy. The relevant output is: ``` pg_resetwal: warning: pg_control exists but has invalid CRC; proceed with caution pg_resetwal: warning: pg_control specifies invalid WAL segment size (-1 bytes); proceed with caution ``` For this build, offset 228 is the xlog_seg_size field. The four bytes written there represent UINT32_MAX, or 4294967295, so the second warning renders the unsigned value as signed. The issue was reproduced on PostgreSQL 18.6 (Debian 18.6-1.pgdg13+2), 64-bit, on Linux/amd64. Source inspection of PostgreSQL 20devel also shows that the uint32 ControlFile.xlog_seg_size value is passed to ngettext format strings using %d; PostgreSQL 20devel was not tested in a recorded runtime execution. This occurs when pg_resetwal diagnoses an invalid WAL segment size stored in a damaged control file.