Re: Ubsan complaint on kestrel

2025-03-03 Thread Tom Lane
Andres Freund writes: > ../../../../../home/andres/src/postgresql/src/backend/nodes/nodeFuncs.c:2712:6: > runtime error: call to function assign_query_collations_walker through > pointer to incorrect function type 'bool (*)(struct Node *, void *)' > /srv/dev/build/postgres/m-dev-assert-clang-san

Re: Ubsan complaint on kestrel

2025-03-03 Thread Andres Freund
Hi, On 2025-03-03 16:49:09 -0500, Tom Lane wrote: > Andres Freund writes: > > I wish the sanitizer treated mismatches of void * arguments against a "real > > type" different from other mismatches, but ... > > Indeed. I think we have enough coverage of that via compile-time > checks, though -- i

Re: Ubsan complaint on kestrel

2025-03-03 Thread Andres Freund
Hi, On 2025-03-03 15:00:43 -0500, Tom Lane wrote: > Andres Freund writes: > > I just upgraded buildfarm animal kestrel (a buildfarm animal running with > > ubsan) to a newer version of clang. Unfortunately this causes it to fail. > > ... > > Tom, do you see any reason to not instead do the typec

Re: Ubsan complaint on kestrel

2025-03-03 Thread Tom Lane
Andres Freund writes: > I just upgraded buildfarm animal kestrel (a buildfarm animal running with > ubsan) to a newer version of clang. Unfortunately this causes it to fail. > ... > Tom, do you see any reason to not instead do the typecase inside > string_compare()? No. Have at it.

Re: UBSan pointer overflow in xlogreader.c

2023-12-08 Thread Robert Haas
On Thu, Dec 7, 2023 at 10:18 PM Thomas Munro wrote: > On Fri, Dec 8, 2023 at 3:57 AM Robert Haas wrote: > > On Tue, Dec 5, 2023 at 4:01 PM Nathan Bossart > > wrote: > > > +1 > > > > So, Thomas ... any chance you could commit this? So that my patch > > stops making cfbot sad? > > Done. Thanks b

Re: UBSan pointer overflow in xlogreader.c

2023-12-07 Thread Thomas Munro
On Fri, Dec 8, 2023 at 3:57 AM Robert Haas wrote: > On Tue, Dec 5, 2023 at 4:01 PM Nathan Bossart > wrote: > > +1 > > So, Thomas ... any chance you could commit this? So that my patch > stops making cfbot sad? Done. Thanks both for the reviews.

Re: UBSan pointer overflow in xlogreader.c

2023-12-07 Thread Robert Haas
On Tue, Dec 5, 2023 at 4:01 PM Nathan Bossart wrote: > +1 So, Thomas ... any chance you could commit this? So that my patch stops making cfbot sad? -- Robert Haas EDB: http://www.enterprisedb.com

Re: UBSan pointer overflow in xlogreader.c

2023-12-05 Thread Nathan Bossart
On Tue, Dec 05, 2023 at 03:48:33PM -0500, Robert Haas wrote: > The patch LGTM, too. Thanks for investigating and writing the code. > The part about how the reserved kernel memory prevents the bug from > appearing on 32-bit systems but not 64-bit systems running in 32-bit > mode is pretty interestin

Re: UBSan pointer overflow in xlogreader.c

2023-12-05 Thread Robert Haas
On Tue, Dec 5, 2023 at 1:04 PM Nathan Bossart wrote: > On Wed, Dec 06, 2023 at 12:03:53AM +1300, Thomas Munro wrote: > > xlogreader.c has a pointer overflow bug, as revealed by the > > combination of -fsanitize=undefined -m32, the new 039_end_of_wal.pl > > test and Robert's incremental backup patc

Re: UBSan pointer overflow in xlogreader.c

2023-12-05 Thread Nathan Bossart
On Wed, Dec 06, 2023 at 12:03:53AM +1300, Thomas Munro wrote: > xlogreader.c has a pointer overflow bug, as revealed by the > combination of -fsanitize=undefined -m32, the new 039_end_of_wal.pl > test and Robert's incremental backup patch[1]. The bad code tests > whether an object could fit using

Re: ubsan

2023-09-27 Thread Alexander Lakhin
Hello Andres, 22.11.2022 02:15, Andres Freund wrote: Hi, On 2022-09-29 18:17:55 -0700, Andres Freund wrote: Attached is a rebased version of this patch. Hopefully with a reasonable amount of comments? I kind of wanted to add a comment to reached_main, but it just seems to end up restating the

Re: ubsan

2022-11-21 Thread Andres Freund
Hi, On November 21, 2022 3:42:38 PM PST, Justin Pryzby wrote: >On Mon, Nov 21, 2022 at 03:15:03PM -0800, Andres Freund wrote: >> Hi, >> >> On 2022-09-29 18:17:55 -0700, Andres Freund wrote: >> > Attached is a rebased version of this patch. Hopefully with a reasonable >> > amount of comments? I

Re: ubsan

2022-11-21 Thread Justin Pryzby
On Mon, Nov 21, 2022 at 03:15:03PM -0800, Andres Freund wrote: > Hi, > > On 2022-09-29 18:17:55 -0700, Andres Freund wrote: > > Attached is a rebased version of this patch. Hopefully with a reasonable > > amount of comments? I kind of wanted to add a comment to reached_main, but > > it > > just

Re: ubsan

2022-11-21 Thread Andres Freund
Hi, On 2022-09-29 18:17:55 -0700, Andres Freund wrote: > Attached is a rebased version of this patch. Hopefully with a reasonable > amount of comments? I kind of wanted to add a comment to reached_main, but it > just seems to end up restating the variable name... I've now pushed a version of thi

Re: ubsan fails on 32bit builds

2022-11-17 Thread Thomas Munro
On Fri, Nov 18, 2022 at 9:13 AM Andres Freund wrote: > Agreed. I had started on a set of patches for some of the SHM_QUEUE uses, but > somehow we ended up a bit stuck on the naming of dlist_delete variant that > afterwards zeroes next/prev so we can replace SHMQueueIsDetached() uses. > > Should pr

Re: ubsan fails on 32bit builds

2022-11-17 Thread Tom Lane
Andres Freund writes: > On 2022-11-17 14:20:47 -0500, Robert Haas wrote: >> Not that I object to a targeted fix > Should we backpatch this fix? Likely this doesn't cause active breakage > outside of 32bit builds under ubsan, but that's not an unreasonable thing to > want to do in the backbranches

Re: ubsan fails on 32bit builds

2022-11-17 Thread Andres Freund
Hi, On 2022-11-17 14:20:47 -0500, Robert Haas wrote: > On Wed, Nov 16, 2022 at 8:42 PM 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, bu

Re: ubsan fails on 32bit builds

2022-11-17 Thread Robert Haas
On Wed, Nov 16, 2022 at 8:42 PM 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 >

Re: ubsan fails on 32bit builds

2022-11-16 Thread Andres Freund
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 >

Re: ubsan

2022-09-29 Thread Andres Freund
Hi, On 2022-03-23 13:54:50 -0400, Tom Lane wrote: > 0002: ugh, but my only real complaint is that __ubsan_default_options > needs more than zero comment. Also, it's not "our" getenv is it? > > 0004: no opinion Attached is a rebased version of this patch. Hopefully with a reasonable amount of co

Re: ubsan

2022-03-25 Thread Andres Freund
Hi, On 2022-03-23 15:55:28 -0700, Andres Freund wrote: > Originally I'd planned to mix them into existing members, but I think it'd be > better to have dedicated ones. Applied for a few new buildfarm names for: > {gcc,clang}-{-fsanitize=undefined,-fsanitize=address}. They're now enabled... taman

Re: ubsan

2022-03-25 Thread David Steele
On 3/23/22 16:55, Andres Freund wrote: It's particularly impressive that the cost of running with ASAN is *so* much lower than valgrind. On my workstation a check-world with -fsanitize=alignment,undefined,address takes 3min17s, vs 1min10s or so without -fsanitize. Not something to always use, b

Re: ubsan

2022-03-23 Thread Noah Misch
On Wed, Mar 23, 2022 at 03:58:09PM -0400, Tom Lane wrote: > Andres Freund writes: > > I think we should backpatch both, based on the reasoning in > > 46ab07ffda9d6c8e63360ded2d4568aa160a7700 ? > > Yeah, I suppose. Is anyone going to step up and run a buildfarm > member with ubsan enabled? thorn

Re: ubsan

2022-03-23 Thread Tom Lane
Andres Freund writes: > Running with asan found an existing use-after-free bug in pg_waldump (*), a > bug in > dshash_seq_next() next that probably can't be hit in HEAD and a bug in my > shared memory stats patch. I count that as a success. Nice! regards, tom lane

Re: ubsan

2022-03-23 Thread Andres Freund
Hi, On 2022-03-23 13:12:34 -0700, Andres Freund wrote: > I'm planning to enable it on two of mine. Looks like gcc and clang find > slightly different things, so I was intending to enable it on one of each. Originally I'd planned to mix them into existing members, but I think it'd be better to hav

Re: ubsan

2022-03-23 Thread Andres Freund
Hi, On 2022-03-23 15:58:09 -0400, Tom Lane wrote: > Andres Freund writes: > > I think we should backpatch both, based on the reasoning in > > 46ab07ffda9d6c8e63360ded2d4568aa160a7700 ? > > Yeah, I suppose. Is anyone going to step up and run a buildfarm > member with ubsan enabled? (I'm already

Re: ubsan

2022-03-23 Thread Tom Lane
Andres Freund writes: > I think we should backpatch both, based on the reasoning in > 46ab07ffda9d6c8e63360ded2d4568aa160a7700 ? Yeah, I suppose. Is anyone going to step up and run a buildfarm member with ubsan enabled? (I'm already checking -fsanitize=alignment on longfin, but it seems advisab

Re: ubsan

2022-03-23 Thread Andres Freund
Hi, On 2022-03-23 11:21:37 -0700, Andres Freund wrote: > On 2022-03-23 13:54:50 -0400, Tom Lane wrote: > > Andres Freund writes: > > > I tried to run postgres with ubsan to debug something. > > > > For 0001, could we just replace configure's dlopen check with the > > dlsym check? Or are you afr

Re: ubsan

2022-03-23 Thread Andres Freund
Hi, On 2022-03-23 13:54:50 -0400, Tom Lane wrote: > Andres Freund writes: > > I tried to run postgres with ubsan to debug something. > > For 0001, could we just replace configure's dlopen check with the > dlsym check? Or are you afraid of reverse-case failures? Yea, I was worried about that. B

Re: ubsan

2022-03-23 Thread Tom Lane
Andres Freund writes: > I tried to run postgres with ubsan to debug something. For 0001, could we just replace configure's dlopen check with the dlsym check? Or are you afraid of reverse-case failures? 0002: ugh, but my only real complaint is that __ubsan_default_options needs more than zero co