pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes
2+ messages / 2 participants
[nested] [flat]
* BUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes
@ 2026-11-11 05:48 PG Bug reporting form <noreply@postgresql.org>
2026-11-11 13:12 ` Re: BUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2026-11-11 05:48 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: 1548140642@qq.com
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:
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=$(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="$d/global/pg_control" bs=1 seek=228 conv=notrunc 2>/dev/null
/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.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes
2026-11-11 05:48 BUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes PG Bug reporting form <noreply@postgresql.org>
@ 2026-11-11 13:12 ` Heikki Linnakangas <hlinnaka@iki.fi>
0 siblings, 0 replies; 2+ messages in thread
From: Heikki Linnakangas @ 2026-11-11 13:12 UTC (permalink / raw)
To: 1548140642@qq.com; pgsql-bugs@lists.postgresql.org
On 11/11/2026 07:48, PG Bug reporting form wrote:
> 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".
This is completely inconsequential.
Peter Eisentraut experimented with -Wformat=signedness a while back, see
https://www.postgresql.org/message-id/a37346d0-96d0-42f1-a5d9-8f31872818c6@eisentraut.org.
This particular change was also covered by those patches.
- Heikki
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-11-11 13:12 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-11 05:48 BUG #19868: pg_resetwal prints uint32 WAL segment size as -1 bytes PG Bug reporting form <noreply@postgresql.org>
2026-11-11 13:12 ` Heikki Linnakangas <hlinnaka@iki.fi>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox