pg_verify_checksums and -fno-strict-aliasing
Michael Banck <michael.banck@credativ.de>
From: Michael Banck <michael.banck@credativ.de>
To: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2018-08-30T08:35:00Z
Lists: pgsql-hackers
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
Commits
-
Avoid using potentially-under-aligned page buffers.
- 44cac9346479 12.0 landed
- 5af055ed7446 9.3.25 landed
- f5c93cf92223 11.0 landed
- 826980424538 9.6.11 landed
- 10b9af3ebbed 10.6 landed
- 083d9ced14e4 9.4.20 landed
- 03ffe5553c1d 9.5.15 landed
-
Code review for pg_verify_checksums.c.
- d787af7badfe 11.0 landed
- d9c366f9e801 12.0 landed
-
Make checksum_impl.h safe to compile with -fstrict-aliasing.
- db87d3b5253f 9.3.25 landed
- 20f9cd55dd53 9.4.20 landed
- 853af991e35a 9.5.15 landed
- d6ef17ed7bba 9.6.11 landed
- c2dfbd18ce25 10.6 landed
- 9daff2fe69dc 11.0 landed
- 8c62d9d16f01 12.0 landed