| From: | Alexander Lakhin <exclusion(at)gmail(dot)com> |
|---|---|
| To: | John Naylor <johncnaylorls(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-21 20:00:00 |
| Message-ID: | ba2ba16a-13bd-4d66-8ce5-753792d7a4ff@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hello John,
21.01.2026 12:05, John Naylor wrote:
> As for the rest of the proposed fixes, most seem okay, but I have some nits:
Thank you for spending time on this!
I agree with all of your changes (except for one noted below) -- didn't
mean to propose committable changes, just wanted to show the fixes that
allowed check-world to pass.
> heaptoast.c
> memcpy(VARDATA(result) +
> - (curchunk * TOAST_MAX_CHUNK_SIZE - sliceoffset) + chcpystrt,
> + (int)(curchunk * TOAST_MAX_CHUNK_SIZE - sliceoffset) + chcpystrt,
>
> Not sure about this one. It would be better if we reversing the
> operands allowed us to avoid overflow in the first place:
>
> - (curchunk * TOAST_MAX_CHUNK_SIZE - sliceoffset) + chcpystrt,
> + chcpystrt + (curchunk * TOAST_MAX_CHUNK_SIZE - sliceoffset)
>
> Does that silence the warning?
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
Best regards,
Alexander
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Viktor Holmberg | 2026-01-21 20:05:18 | Re: ON CONFLICT DO SELECT (take 3) |
| Previous Message | Jeff Davis | 2026-01-21 19:30:14 | Re: Remaining dependency on setlocale() |