Re: Back-patch v19 improvements to common/int128.h?

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Nathan Bossart <nathandbossart(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Back-patch v19 improvements to common/int128.h?
Date: 2026-12-03 23:26:18
Message-ID: CAN4CZFMZNMZyim=NDM9MvaXrDP82P_tJH9BWutSu_6p5Df8TKA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Another issue/thread is [1] that could be simpler with back-patched int128.

> FWIW, I just asked Claude Sonnet to review it, and it reported no active bugs.

Fable pointed out that there's one UB in non-native int128_div_mod_int32
src/include/common/int128.h:350: d = abs(v); is UB for v = INT32_MIN.
Comment above explicitly allows |v| = 2^31.
gcc -m32 -O2/-O3/-Os without -fwrapv returns wrong quotients: 2^64 /
INT32_MIN gives 0, should be -2^33.

As postgres currently uses fwrapv this seems like a nit and definitely
not a reason against back-patching, but there were already multiple
commits in the past removing fwrapv dependence, so I thought it is
worth at least a mention.

[1]: https://www.postgresql.org/message-id/CAEPgAbE%2BV7Wgx-1BYap276v_Ohc7Zk2HV3-U8Wp520Jz84NRmg%40mail.gmail.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Baji Shaik 2026-12-03 23:36:14 Re: [PATCH] pageinspect: validate line pointers before using them
Previous Message Baji Shaik 2026-12-03 22:54:58 Re: pg_dump writes a subscription's default slot name, which can't be restored