Re: Fix runtime errors from -fsanitize=undefined - Mailing list pgsql-hackers

From Noah Misch
Subject Re: Fix runtime errors from -fsanitize=undefined
Date
Msg-id 20190704233353.GA1397438@rfd.leadboat.com
Whole thread Raw
In response to Fix runtime errors from -fsanitize=undefined  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Responses Re: Fix runtime errors from -fsanitize=undefined
List pgsql-hackers
On Mon, Jun 03, 2019 at 09:21:48PM +0200, Peter Eisentraut wrote:
> After many years of trying, it seems the -fsanitize=undefined checking
> in gcc is now working somewhat reliably.  Attached is a patch that fixes
> all errors of the kind
> 
> runtime error: null pointer passed as argument N, which is declared to
> never be null
> 
> Most of the cases are calls to memcpy(), memcmp(), etc. with a length of
> zero, so one appears to get away with passing a null pointer.

I just saw this proposal.  The undefined behavior in question is strictly
academic.  These changes do remove the need for new users to discover
-fno-sanitize=nonnull-attribute, but they make the code longer and no clearer.
Given the variety of code this touches, I expect future commits will
reintroduce the complained-of usage patterns, prompting yet more commits to
restore the invariant achieved here.  Hence, I'm -0 for this change.



pgsql-hackers by date:

Previous
From: Jose Luis Tallon
Date:
Subject: Re: [PATCH] Implement uuid_version()
Next
From: Peter Geoghegan
Date:
Subject: Re: [HACKERS] [WIP] Effective storage of duplicates in B-tree index.