Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvVAU-0005xx-0n for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Aug 2018 22:11:58 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fvVAR-0008JF-PG for pgsql-hackers@arkaria.postgresql.org; Thu, 30 Aug 2018 22:11:55 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvVAR-0008I3-IL for pgsql-hackers@lists.postgresql.org; Thu, 30 Aug 2018 22:11:55 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fvVAJ-0003MI-EW for pgsql-hackers@postgresql.org; Thu, 30 Aug 2018 22:11:55 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id w7UMBeUi028545; Thu, 30 Aug 2018 18:11:40 -0400 From: Tom Lane To: Andres Freund cc: Michael Banck , Magnus Hagander , Fabien COELHO , pgsql-hackers Subject: Re: pg_verify_checksums and -fno-strict-aliasing In-reply-to: <20180830220409.4zhdka6ibs66enbk@alap3.anarazel.de> References: <1535618100.1286.3.camel@credativ.de> <7321.1535639966@sss.pgh.pa.us> <1535660901.1286.8.camel@credativ.de> <25968.1535663968@sss.pgh.pa.us> <20180830214606.xpm4bho5nmhfuzlx@alap3.anarazel.de> <20180830220409.4zhdka6ibs66enbk@alap3.anarazel.de> Comments: In-reply-to Andres Freund message dated "Thu, 30 Aug 2018 15:04:09 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <28543.1535667100.1@sss.pgh.pa.us> Date: Thu, 30 Aug 2018 18:11:40 -0400 Message-ID: <28544.1535667100@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Andres Freund writes: > On 2018-08-30 14:46:06 -0700, Andres Freund wrote: >> One way to fix it would be to memcpy in/out the modified PageHeader, or >> just do offset math and memcpy to that offset. > It took me a bit to reproduce the issue (due to sheer stupidity on my > part: no, changing the flags passed to gcc to link pg_verify_checksums > doesn't do the trick), but the above indeed fixes the issue for me. I suspect people will complain about the added cost of doing that. I've been AFK all afternoon, but what I was intending to try next was the union approach, specifically union'ing PageHeaderData with the uint32 array representation needed by pg_checksum_block(). That might also end up giving us code less unreadable than this: uint32 (*dataArr)[N_SUMS] = (uint32 (*)[N_SUMS]) data; BTW, not to mention the elephant in the room, but: is it *really* OK that pg_checksum_page scribbles on the page buffer, even temporarily? It's certainly quite horrid that there aren't large warnings about that in the function's API comment. regards, tom lane