public inbox for [email protected]
help / color / mirror / Atom feedFrom: Michael Paquier <[email protected]>
To: Kyotaro Horiguchi <[email protected]>
Cc: [email protected]
Cc: [email protected]
Subject: Re: Set huge_page_size on 32bit system
Date: Fri, 26 Jun 2026 14:26:31 +0900
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAMp4U1d177Jf9ZJwXGKom6APx3LSFATa=Z-M=N5kLzvTUcxutw@mail.gmail.com>
<[email protected]>
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
Attachments:
[application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
download
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Set huge_page_size on 32bit system
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox