Re: Set huge_page_size on 32bit system
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: vilensipkdm@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2026-06-26T05:26:31Z
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
Commits
-
Switch maximum of GUC huge_page_size to MAX_KILOBYTES
- dbaa4dc3c8dd 19 (unreleased) landed