Re: Undefined behavior detected by new clang's ubsan
John Naylor <johncnaylorls@gmail.com>
From: John Naylor <johncnaylorls@gmail.com>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>, Tom Lane <tgl@sss.pgh.pa.us>
Date: 2026-01-29T11:25:50Z
Lists: pgsql-hackers
On Thu, Jan 22, 2026 at 12:14 PM John Naylor <johncnaylorls@gmail.com> wrote: > > On Thu, Jan 22, 2026 at 3:00 AM Alexander Lakhin <exclusion@gmail.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
Commits
-
Future-proof sort template against undefined behavior
- 7467041cde9e 19 (unreleased) landed
-
Fix various instances of undefined behavior
- 176dffdf7d2a 19 (unreleased) landed
- fc56793c9ae5 14.21 landed
- b5e1cd2fdca1 18.2 landed
- 73ac2b37401d 16.12 landed
- 6b81a1c7c905 15.16 landed
- 1662cd0cb7ae 17.8 landed