Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vBbgu-001HMQ-Ni for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Oct 2025 16:28:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vBbgt-0008r1-4c for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Oct 2025 16:27:58 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vBbgs-0008qr-RE for pgsql-hackers@lists.postgresql.org; Wed, 22 Oct 2025 16:27:57 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vBbgp-003BwY-2n for pgsql-hackers@lists.postgresql.org; Wed, 22 Oct 2025 16:27:56 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 59MGRsSD799985; Wed, 22 Oct 2025 12:27:54 -0400 From: Tom Lane To: Robert Haas cc: Thomas Munro , pgsql-hackers@lists.postgresql.org Subject: Re: Dynamic shared memory areas In-reply-to: References: Comments: In-reply-to Robert Haas message dated "Fri, 02 Dec 2016 13:21:17 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <799983.1761150474.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 22 Oct 2025 12:27:54 -0400 Message-ID: <799984.1761150474@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk [ blast-from-the-past department ] Robert Haas writes: > On Thu, Dec 1, 2016 at 6:33 AM, Thomas Munro > wrote: >> Please find attached dsa-v8.patch, and also a small test module for >> running random allocate/free exercises and dumping the internal >> allocator state. > OK, I've committed the main patch. Our shiny new version of Coverity kvetches about FreePageBtreeInsertInternal: *** CID 1667414: (OVERRUN) /srv/coverity/git/pgsql-git/postgresql/src/backend/utils/mmgr/freepage.c: = 908 in FreePageBtreeInsertInternal() 902 { 903 Assert(btp->hdr.magic =3D=3D FREE_PAGE_INTERNAL_MAGIC); 904 Assert(btp->hdr.nused <=3D FPM_ITEMS_PER_INTERNAL_PAGE); 905 Assert(index <=3D btp->hdr.nused); 906 memmove(&btp->u.internal_key[index + 1], &btp->u.internal_key[= index], 907 sizeof(FreePageBtreeInternalKey) * (btp->hdr.nused - i= ndex)); >>> CID 1667414: (OVERRUN) >>> Overrunning array "btp->u.internal_key" of 254 16-byte elements at= element index 254 (byte offset 4079) using index "index" (which evaluates= to 254). 908 btp->u.internal_key[index].first_page =3D first_page; 909 relptr_store(base, btp->u.internal_key[index].child, child); 910 ++btp->hdr.nused; 911 } I believe the reason is that the second Assert is wrong, and it should instead be 904 Assert(btp->hdr.nused < FPM_ITEMS_PER_INTERNAL_PAGE); to assert that there is room for the item we are about to insert. The same thinko exists in FreePageBtreeInsertLeaf, although for some reason Coverity isn't whining about that. Thoughts? regards, tom lane