Re: Fix runtime errors from -fsanitize=undefined

From: didier <did447(at)gmail(dot)com>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Fix runtime errors from -fsanitize=undefined
Date: 2019-06-29 16:16:45
Message-ID: CAJRYxuKaP5oWOGaUEt8dXEO8kN5=8BuP3+mOUCFDDwUiWc12sA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

I tested this patch with clang 7 on master.
- On unpatched master I can't reproduce errors with make check-world in:
src/backend/access/heap/heapam.c
src/backend/utils/cache/relcache.c (IIRC I triggered this one in a pg
previous version)
src/backend/utils/misc/guc.c

- I have a hard to reproduce one not in this patched:
src/backend/storage/ipc/shm_mq.c line 727

About the changes
- in
src/fe_utils/print.c
line memset(header_done, false, col_count * sizeof(bool));
is redundant and should be remove not guarded with if (hearder_done),
header_done is either null or already zeroed, it's pg_malloc0 ed.

In all cases but one patched version shortcut an undefined no ops but in
src/backend/access/transam/clog.c
memcmp 0 bytes return 0 thus current change modifies code path, before
with nsubxids == 0 if branch was taken now it's not.
Could wait more often while taking lock, no idea if it's relevant.

Regards
Didier

On Thu, Jun 6, 2019 at 11:36 AM Peter Eisentraut
<peter(dot)eisentraut(at)2ndquadrant(dot)com> wrote:
>
> On 2019-06-05 21:30, Robert Haas wrote:
> > On Mon, Jun 3, 2019 at 3:22 PM Peter Eisentraut
> > <peter(dot)eisentraut(at)2ndquadrant(dot)com> 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
> >
> > Is this as of some particular gcc version?
>
> I used gcc-8.
>
> The option has existed in gcc for quite some time, but in previous
> releases it always tended to hang or get confused somewhere.
>
> --
> Peter Eisentraut http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
>
>

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Korotkov 2019-06-29 17:06:47 Re: Avoid full GIN index scan when possible
Previous Message Tomas Vondra 2019-06-29 14:27:26 Re: Avoid full GIN index scan when possible