Re: Undefined behavior detected by new clang's ubsan

From: John Naylor <johncnaylorls(at)gmail(dot)com>
To: Alexander Lakhin <exclusion(at)gmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Undefined behavior detected by new clang's ubsan
Date: 2026-01-29 11:25:50
Message-ID: CANWCAZYsbztVBRE4U25MRRUmu=9fCJ5cE6V+8G1abOnGCN1XLA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Jan 22, 2026 at 12:14 PM John Naylor <johncnaylorls(at)gmail(dot)com> wrote:
>
> On Thu, Jan 22, 2026 at 3:00 AM Alexander Lakhin <exclusion(at)gmail(dot)com> wrote:
> > Unfortunately, no -- I still got:
> > heaptoast.c:771:17: runtime error: addition of unsigned offset to 0x78120673fac6 overflowed to 0x78120673fa04
> > SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior heaptoast.c:771:17
>
> Okay, I'll refrain from guessing more then. I'm due for an OS upgrade
> anyway, and that'll have clang 21, so I'll come back to this one
> unless someone beats me to it.

Small update: With clang 21 I've confirmed the behavior Alexander
found, and confirmed my v1 patches fix the warnings except for the one
in heap_fetch_toast_slice() that I skipped over. I'd like to
understand that one better, in case a more principled fix can be
found.

--
John Naylor
Amazon Web Services

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message John Naylor 2026-01-29 11:31:53 Re: refactor architecture-specific popcount code
Previous Message Mircea Cadariu 2026-01-29 11:19:05 Re: parallel data loading for pgbench -i