Re: ubsan fails on 32bit builds
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@postgresql.org, Fujii Masao <masao.fujii@oss.nttdata.com>, torikoshia <torikoshia@oss.nttdata.com>
Date: 2022-11-17T19:20:47Z
Lists: pgsql-hackers
On Wed, Nov 16, 2022 at 8:42 PM Andres Freund <andres@anarazel.de> 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. Not that I object to a targeted fix, but it's been 10 years since slist and dlist were committed, and we really ought to eliminate SHM_QUEUE entirely in favor of using those. It's basically an open-coded implementation of something for which we now have a toolkit. Not that it's impossible to make this kind of mistake with a toolkit, but in general open-coding the same logic in multiple places increases the risk of bugs. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Fix mislabeling of PROC_QUEUE->links as PGPROC, fixing UBSan on 32bit
- 140c80372327 11.19 landed
- 4cbcb7ed85b0 12.14 landed
- c13667b518e3 13.10 landed
- fc4154286e0e 14.7 landed
- a0d35ebcc570 15.2 landed
- 8c954168cff4 16.0 landed