pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Banck <michael.banck@credativ.de>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Subject: pg_verify_checksums and -fno-strict-aliasing
Date: Thu, 30 Aug 2018 10:35:00 +0200
Message-ID: <1535618100.1286.3.camel@credativ.de> (raw)

Hi,

I noticed that pg_verify_checksums computes bogus checksums if I compile
it with '-O2 -Wall' but without -fno-strict-aliasing. Also I am getting
a compile warning then:

|src/bin/pg_verify_checksums$ make CFLAGS='-g -O2 -Wall'
[...]
|gcc -g -O2 -Wall -I../../../src/include 
|  -I/home/mba/Projekte/OSS/PostgreSQL/git/postgresql/build/../src/include
|  -D_GNU_SOURCE   -c -o pg_verify_checksums.o
|  /home/mba/Projekte/OSS/PostgreSQL/git/postgresql/build/../src/bin/pg_verify_checksums/pg_verify_checksums.c
|  -MMD -MP -MF .deps/pg_verify_checksums.Po
|/home/mba/Projekte/OSS/PostgreSQL/git/postgresql/build/../src/bin/pg_verify_checksums/pg_verify_checksums.c: 
|  In function ‘scan_file’:
|/home/mba/Projekte/OSS/PostgreSQL/git/postgresql/build/../src/bin/pg_verify_checksums/pg_verify_checksums.c:112:3: 
|  warning: dereferencing type-punned pointer will break strict-aliasing
|  rules [-Wstrict-aliasing]
|   if (PageIsNew(buf))
|   ^~
[...]
|src/bin/pg_verify_checksums$ ./pg_verify_checksums -D ../../test/regress/tmp_check/data
|pg_verify_checksums: checksum verification failed in file "../../test/regress/tmp_check/data/global/1233", block 0: calculated checksum FC8A but expected F857
|pg_verify_checksums: checksum verification failed in file "../../test/regress/tmp_check/data/global/1233", block 1: calculated checksum F340 but expected A68D
[...]
|pg_verify_checksums: checksum verification failed in file "../../test/regress/tmp_check/data/base/12368/2659", block 5: calculated checksum 954D but expected D2ED
|pg_verify_checksums: checksum verification failed in file "../../test/regress/tmp_check/data/base/12368/2659", block 6: calculated checksum 361 but expected E7F7
|pg_verify_checksums: checksum verification failed in file "../../test/regress/tmp_check/data/base/12368/2659", block 7: calculated checksum 4C0D but expected 4B10
|pg_verify_checksums: checksum verification failed in file "../../test/regress/tmp_check/data/base/12368/2659", block 8: calculated checksum 2B9A but expected 71E3
|pg_verify_checksums: checksum verification failed in file "../../test/regress/tmp_check/data/base/12368/2659", block 9: calculated checksum 19CD but expected 541C
|Checksum scan completed
|Data checksum version: 1
|Files scanned:  932
|Blocks scanned: 2789
|Bad checksums:  2789

If I add -fno-strict-aliasing to $CFLAGS, the problem goes away.

Is this something to worry about, or just pilot error cause I am not
using the same $CFLAGS as for the rest of the build? I originally
noticed this problem with my external fork of pg_verify_checksums.


Michael

-- 
Michael Banck
Projektleiter / Senior Berater
Tel.: +49 2166 9901-171
Fax:  +49 2166 9901-100
Email: michael.banck@credativ.de

credativ GmbH, HRB Mönchengladbach 12080
USt-ID-Nummer: DE204566209
Trompeterallee 108, 41189 Mönchengladbach
Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer

Unser Umgang mit personenbezogenen Daten unterliegt
folgenden Bestimmungen: https://www.credativ.de/datenschutz




view thread (34+ messages)  latest in thread

Message-ID: <1535618100.1286.3.camel@credativ.de>
Permalink:  ../1535618100.1286.3.camel@credativ.de/
Also on:    postgresql.org/message-id/1535618100.1286.3.camel@credativ.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: michael.banck@credativ.de
  Subject: Re: pg_verify_checksums and -fno-strict-aliasing
  In-Reply-To: <1535618100.1286.3.camel@credativ.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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