| From: | Michael Paquier <michael(at)paquier(dot)xyz> |
|---|---|
| To: | Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com> |
| Cc: | vilensipkdm(at)gmail(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org |
| Subject: | Re: Set huge_page_size on 32bit system |
| Date: | 2026-06-26 05:26:31 |
| Message-ID: | aj4Nh0a9WiZXAjA5@paquier.xyz |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Fri, Jun 26, 2026 at 01:24:15PM +0900, Kyotaro Horiguchi wrote:
> We could also make the later calculation use a wider integer type, but
> such a value would not be usable anyway on a platform where it does
> not fit in Size. So it seems better to reject it earlier in
> check_huge_page_size(), before reaching CreateAnonymousSegment().
The top of guc.h includes the following thing:
/*
* Maximum for integer GUC variables that are measured in kilobytes of memory.
* This value is chosen to ensure that the corresponding number of bytes fits
* into a variable of type size_t or ssize_t. Be sure to compute the number
* of bytes like "guc_var * (Size) 1024" to avoid int-width overflow.
*/
#if SIZEOF_SIZE_T > 4
#define MAX_KILOBYTES INT_MAX
#else
#define MAX_KILOBYTES (INT_MAX / 1024)
#endif
So it seems to me that the mistake is that huge_page_size uses INT_MAX
as upper bound. We should use MAX_KILOBYTES instead; this definition
exists to exactly prevent this kind of computation mistake in 32b
environments.
--
Michael
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Hüseyin Demir | 2026-06-26 06:56:00 | Re: BUG #19483: pg_upgrade fails with orphan records in pg_init_priv catalog table |
| Previous Message | Laurenz Albe | 2026-06-26 05:18:28 | Re: BUG #19483: pg_upgrade fails with orphan records in pg_init_priv catalog table |