public inbox for [email protected]  
help / color / mirror / Atom feed
From: Daria Shanina <[email protected]>
To: [email protected]
Subject: Set huge_page_size on 32bit system
Date: Thu, 25 Jun 2026 17:54:46 +0300
Message-ID: <CAMp4U1d177Jf9ZJwXGKom6APx3LSFATa=Z-M=N5kLzvTUcxutw@mail.gmail.com> (raw)

Hi all,

I found an error: on 32bit system (I tested on Debian 6.1.0-32-686-pae #1
SMP PREEMPT_DYNAMIC Debian 6.1.129-1 (2025-03-06) i686 GNU/Linux) when we
set huge_page_size = 1 TB postgres process fails with signal SIGFPE when
calculated hugepagesize_local = (Size) huge_page_size * 1024; the value
exceeds max for unsigned int = (2^32 – 1).
I attached a full backtrace and one small fix.

What do you think about this?
Thank you for your attention!

--
Best regards,
Daria Shanina

Starting program: /home/vboxuser/projects/psql/bugfix_pgpro7219/master/build/bin/postgres 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGFPE, Arithmetic exception.
0x0096ef81 in CreateAnonymousSegment (size=0xbfffeef0) at pg_shmem.c:621
621			if (allocsize % hugepagesize != 0)
#0  0x0096ef81 in CreateAnonymousSegment (size=0xbfffeef0) at pg_shmem.c:621
        hugepagesize = 0
        huge_mmap_flags = 262144
        allocsize = 154329088
        ptr = 0xffffffff
        mmap_errno = 0
        mmap_flags = 33
        __func__ = "CreateAnonymousSegment"
#1  0x0096f2ff in PGSharedMemoryCreate (size=154329088, shim=0xbfffef04) at pg_shmem.c:741
        NextShmemSegID = 10759567
        memAddress = 0x932d738
        hdr = 0xc78b6e <errstart+169>
        statbuf = {st_dev = 2049, __pad1 = 0, __st_ino = 0, st_mode = 16832, st_nlink = 19, st_uid = 1000, st_gid = 1000, st_rdev = 0, __pad2 = 0, st_size = 4096, st_blksize = 4096, st_blocks = 8, st_atim = {tv_sec = 1782287996, tv_nsec = 729867291}, st_mtim = {tv_sec = 1782288163, tv_nsec = 798191630}, st_ctim = {tv_sec = 1782288163, tv_nsec = 798191630}, st_ino = 1189604}
        sysvsize = 61176
        __func__ = "PGSharedMemoryCreate"
#2  0x00a42e78 in CreateSharedMemoryAndSemaphores () at ipci.c:135
        shim = 0x94
        seghdr = 0x932e000
        size = 154329088
        __func__ = "CreateSharedMemoryAndSemaphores"
#3  0x0097f34a in PostmasterMain (argc=1, argv=0x1134ba0) at postmaster.c:1018
        optctx = {nargc = 1, nargv = 0x1134ba0, ostr = 0xe93138 "B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:", opterr = 1, optarg = 0x0, optind = 1, optopt = 0, place = 0xf976bc ""}
        opt = -1
        status = 8596279
        userDoption = 0x0
        listen_addr_saved = false
        output_config_variable = 0x0
        __func__ = "PostmasterMain"
#4  0x008324b6 in main (argc=1, argv=0x1134ba0) at main.c:231
        do_check_root = true
        dispatch_option = DISPATCH_POSTMASTER


Attachments:

  [text/plain] gdb.txt (2.0K, ../CAMp4U1d177Jf9ZJwXGKom6APx3LSFATa=Z-M=N5kLzvTUcxutw@mail.gmail.com/3-gdb.txt)
  download | inline:
Starting program: /home/vboxuser/projects/psql/bugfix_pgpro7219/master/build/bin/postgres 
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/i386-linux-gnu/libthread_db.so.1".

Program received signal SIGFPE, Arithmetic exception.
0x0096ef81 in CreateAnonymousSegment (size=0xbfffeef0) at pg_shmem.c:621
621			if (allocsize % hugepagesize != 0)
#0  0x0096ef81 in CreateAnonymousSegment (size=0xbfffeef0) at pg_shmem.c:621
        hugepagesize = 0
        huge_mmap_flags = 262144
        allocsize = 154329088
        ptr = 0xffffffff
        mmap_errno = 0
        mmap_flags = 33
        __func__ = "CreateAnonymousSegment"
#1  0x0096f2ff in PGSharedMemoryCreate (size=154329088, shim=0xbfffef04) at pg_shmem.c:741
        NextShmemSegID = 10759567
        memAddress = 0x932d738
        hdr = 0xc78b6e <errstart+169>
        statbuf = {st_dev = 2049, __pad1 = 0, __st_ino = 0, st_mode = 16832, st_nlink = 19, st_uid = 1000, st_gid = 1000, st_rdev = 0, __pad2 = 0, st_size = 4096, st_blksize = 4096, st_blocks = 8, st_atim = {tv_sec = 1782287996, tv_nsec = 729867291}, st_mtim = {tv_sec = 1782288163, tv_nsec = 798191630}, st_ctim = {tv_sec = 1782288163, tv_nsec = 798191630}, st_ino = 1189604}
        sysvsize = 61176
        __func__ = "PGSharedMemoryCreate"
#2  0x00a42e78 in CreateSharedMemoryAndSemaphores () at ipci.c:135
        shim = 0x94
        seghdr = 0x932e000
        size = 154329088
        __func__ = "CreateSharedMemoryAndSemaphores"
#3  0x0097f34a in PostmasterMain (argc=1, argv=0x1134ba0) at postmaster.c:1018
        optctx = {nargc = 1, nargv = 0x1134ba0, ostr = 0xe93138 "B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:", opterr = 1, optarg = 0x0, optind = 1, optopt = 0, place = 0xf976bc ""}
        opt = -1
        status = 8596279
        userDoption = 0x0
        listen_addr_saved = false
        output_config_variable = 0x0
        __func__ = "PostmasterMain"
#4  0x008324b6 in main (argc=1, argv=0x1134ba0) at main.c:231
        do_check_root = true
        dispatch_option = DISPATCH_POSTMASTER

  [text/x-patch] fix-for-huge_page_size.patch (731B, ../CAMp4U1d177Jf9ZJwXGKom6APx3LSFATa=Z-M=N5kLzvTUcxutw@mail.gmail.com/4-fix-for-huge_page_size.patch)
  download | inline diff:
diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c
index 2e3886cf9fe..8bb31698bd0 100644
--- a/src/backend/port/sysv_shmem.c
+++ b/src/backend/port/sysv_shmem.c
@@ -618,6 +618,13 @@ CreateAnonymousSegment(Size *size)
 
 		GetHugePageSize(&hugepagesize, &huge_mmap_flags);
 
+		if (hugepagesize == 0)
+			ereport(ERROR,
+				(errcode(ERRCODE_OUT_OF_MEMORY),
+				 errmsg("Cannot alocate %d bytes of memory", hugepagesize),
+				 errhint("It is necessary to reduce the amount of the configuration parameter \'huge_page_size\' (currently huge_page_size %d kB)", 
+					huge_page_size)));
+
 		if (allocsize % hugepagesize != 0)
 			allocsize = add_size(allocsize, hugepagesize - (allocsize % hugepagesize));
 


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]
  Subject: Re: Set huge_page_size on 32bit system
  In-Reply-To: <CAMp4U1d177Jf9ZJwXGKom6APx3LSFATa=Z-M=N5kLzvTUcxutw@mail.gmail.com>

* 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