Re: ubsan fails on 32bit builds - Mailing list pgsql-hackers

From Andres Freund
Subject Re: ubsan fails on 32bit builds
Date
Msg-id 20221117072821.5xufyalfyc2bml6o@awork3.anarazel.de
Whole thread Raw
In response to ubsan fails on 32bit builds  (Andres Freund <andres@anarazel.de>)
List pgsql-hackers
Hi,

On 2022-11-16 17:42:30 -0800, Andres Freund wrote:
> Afaict the problem is that
>         proc = (PGPROC *) &(waitQueue->links);
> 
> is a gross gross hack - this isn't actually a PGPROC, it's pointing to an
> SHM_QUEUE, but *not* one embedded in PGPROC.  It kinda works because ->links
> is at offset 0 in PGPROC, which means that
>     SHMQueueInsertBefore(&(proc->links), &(MyProc->links));
> will turn &proc->links back into waitQueue->links. Which we then can enqueue
> again.
> 
> I don't see the point of this hack, even leaving ubsan's valid complaints
> aside. Why bother having this, sometimes, fake PGPROC pointer when we could
> just use a SHM_QUEUE* to determine the insertion point?

As done in the attached patch. With this ubsan passes both on 32bit and 64bit.

Greetings,

Andres Freund

Attachment

pgsql-hackers by date:

Previous
From: Maciek Sakrejda
Date:
Subject: Odd behavior with pg_stat_statements and queries called from SQL functions
Next
From: Thomas Munro
Date:
Subject: Re: Assertion failure with barriers in parallel hash join