Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oVOYd-0007Rh-4Y for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Sep 2022 02:43:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oVOYb-00083f-Rr for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Sep 2022 02:43:21 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oVOYb-00083W-Ix for pgsql-hackers@lists.postgresql.org; Tue, 06 Sep 2022 02:43:21 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oVOYZ-0008Hp-Jm for pgsql-hackers@lists.postgresql.org; Tue, 06 Sep 2022 02:43:21 +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 2862hEwE3021144; Mon, 5 Sep 2022 22:43:14 -0400 From: Tom Lane To: David Rowley cc: Andres Freund , Robert Haas , Yura Sokolov , PostgreSQL Developers Subject: Re: Reducing the chunk header sizes on all memory context types In-reply-to: References: <20220809184410.g6yzu6pvttuphag5@awork3.anarazel.de> <20220905230949.kb3x2fkpfwtngz43@awork3.anarazel.de> <3000301.1662424054@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Tue, 06 Sep 2022 14:32:42 +1200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3021142.1662432194.1@sss.pgh.pa.us> Date: Mon, 05 Sep 2022 22:43:14 -0400 Message-ID: <3021143.1662432194@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > I think the fix is harder than I thought, or perhaps impossible to do > given how we now determine the owning MemoryContext of a pointer. > There's a comment in MemoryContextContains which says: > * NB: Can't use GetMemoryChunkContext() here - that performs assertions > * that aren't acceptable here since we might be passed memory not > * allocated by any memory context. I think MemoryContextContains' charter is to return GetMemoryChunkContext(pointer) == context *except* that instead of asserting what GetMemoryChunkContext asserts, it should treat those cases as reasons to return false. So if you can still do GetMemoryChunkContext then you can still do MemoryContextContains. The point of having the separate function is to be as forgiving as we can of bogus pointers. regards, tom lane