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 1tiHoA-00Dy00-Rh for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 18:50:03 +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 1tiHo8-00CPjk-CO for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 18:50:01 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tiHo7-00CPjc-O0 for pgsql-hackers@lists.postgresql.org; Wed, 12 Feb 2025 18:50:00 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tiHo5-000U6z-1O for pgsql-hackers@postgresql.org; Wed, 12 Feb 2025 18:50:00 +0000 Received: from phl-compute-09.internal (phl-compute-09.phl.internal [10.202.2.49]) by mailfhigh.phl.internal (Postfix) with ESMTP id C59611140151; Wed, 12 Feb 2025 13:49:54 -0500 (EST) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-09.internal (MEProxy); Wed, 12 Feb 2025 13:49:54 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ilmari.org; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1739386194; x=1739472594; bh=gaAapKOy7G 7IaSqVWAEEnP77duKBhnIF/6y7vc4Dd9k=; b=DUQTSQeJE0uLkomkaYssCsuO1J 1g8CJQ4/Q0EbuXSvuQoJI2VOPmpHRPP8ZvUPfI+gka5PJFYfWFymr+Jro6HPDAql GQt96A9QqZsvRxH95TOU40cWhIGi5F2J9ByOT7e9xkUBvo571n0TWxa0YFYMCqqk lrnZMUG090g3RB+FVMLlB2hyzmqBLLH2ibjNYJZvv7DEVJYu/7d8NbSmOef4gVOQ XeHqqTdiFrCW/5EadRSKrL2g6rHeRZ6pOdmVYzU0GvYtCu6zuqWtSVkqpq0L7vpz CsIdE0XxKJhvdIkK3f8poqCOXslBYAu1KQa3uXJBTt2imcSuFvXTo5uciPiQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1739386194; x=1739472594; bh=gaAapKOy7G7IaSqVWAEEnP77duKBhnIF/6y 7vc4Dd9k=; b=IjpAaSRMs3INjj84Pk3JVlTZXoFMFMj9sCCoH9R0VwtI6EJ33+v VTyE90m8HEYJacA/QfRRToIMsUiaZ95VlE2S+by7+d2UALVqcbfRI9c6j2VfUWae qEMmphnL2Rf+H2S7xP0nGWJROmYocDwg2cj7GE9qx8oUMTLZVEqkFBx+D6gVNVmO 4WLxBGJS6mZ4sd0NTZF/CQCV6XqJqJ/oqJwuDBDu4PdQrcFE5T1VIT78vzBky4PA KpwjduyxjCjEDJThUAC3NNQnrX+tudA+qb3bKSABF3Blrobb70AccTA9AQ/+NU17 f2ONfb3VIj/oMsGDI8W2oW4J8bDq2Qn7gtw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefvddrtddtgdeggeeihecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvfevufhfffgjkfgfgggtsehttdertddtreej necuhfhrohhmpeffrghgfhhinhhnucfklhhmrghrihcuofgrnhhnshonkhgvrhcuoehilh hmrghrihesihhlmhgrrhhirdhorhhgqeenucggtffrrghtthgvrhhnpedvvedtvdejvedv feeuhfduteelleffvdegueejhfehvddvtedugeeuledtudefhfenucffohhmrghinheplh hlvhhmrdhorhhgnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhf rhhomhepihhlmhgrrhhisehilhhmrghrihdrohhrghdpnhgspghrtghpthhtohephedpmh houggvpehsmhhtphhouhhtpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphho shhtghhrvghsqhhlrdhorhhgpdhrtghpthhtoheprhgrnhhivghrrdhvfhesghhmrghilh drtghomhdprhgtphhtthhopegvuhhlvghrsegvuhhlvghrthhordgtohhmpdhrtghpthht oheprghnughrvghssegrnhgrrhgriigvlhdruggvpdhrtghpthhtohepthhglhesshhssh drphhghhdrphgrrdhush X-ME-Proxy: Feedback-ID: i1ff147bf:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 12 Feb 2025 13:49:53 -0500 (EST) From: =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= To: Tom Lane Cc: Andres Freund , Euler Taveira , "ranier.vf@gmail.com" , pgsql-hackers Subject: Re: Small memory fixes for pg_createsubcriber References: <68d6d810-4ef1-4f62-b47f-89b21501249b@app.fastmail.com> <3337507.1739376124@sss.pgh.pa.us> <878qqb2ibm.fsf@wibble.ilmari.org> <3355447.1739380997@sss.pgh.pa.us> <875xlf2hre.fsf@wibble.ilmari.org> <3357824.1739381901@sss.pgh.pa.us> Date: Wed, 12 Feb 2025 18:49:52 +0000 In-Reply-To: <3357824.1739381901@sss.pgh.pa.us> (Tom Lane's message of "Wed, 12 Feb 2025 12:38:21 -0500") Message-ID: <8734gj2e27.fsf@wibble.ilmari.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Tom Lane writes: > =?utf-8?Q?Dagfinn_Ilmari_Manns=C3=A5ker?= writes: >> Tom Lane writes: >>> libpq-fe.h has to be compilable by application code that has never >>> heard of pg_config.h let alone c.h, so we'd have to tread carefully >>> about not breaking that property. But it seems like this would be >>> worth looking into. > >> The fallback code isn't exactly complicated, so we could just duplicate >> it in libpq-fe.h: > >> #ifndef __has_attribute >> #define __has_attribute(attribute) 0 >> #endif > > The problem with that approach is the likelihood of stomping on > symbols that a calling application will use later. I think we > really need a controlling #ifdef check on some PG_FOO symbol > that we can be sure no outside application will have defined. > Roughly speaking, > > #ifdef PG_USE_ALLOCATOR_CHECKS As long as we're not checking for too many attributes, we could avoid introducing the __has_attribute symbol by doing: #if defined(__has_attribute) && __has_attribute(malloc) > #define pg_attribute_malloc __attribute__((malloc)) > ... > #else > #define pg_attribute_malloc > ... > #endif > > and then we could make definition of PG_USE_ALLOCATOR_CHECKS > be conditional on having the right compiler behavior, rather > than trusting that a nest of #ifdef checks is sufficient to > detect that. But I just looked at the clang attribute docs (https://clang.llvm.org/docs/AttributeReference.html#malloc), and it only has the argumentless version, not the one that that declares the matching deallocator, so you're right we need a more comprehensive check. > regards, tom lane - ilmari