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 1tiFBl-00DMys-8f for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 16:02:13 +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 1tiFBj-00AUYV-4T for pgsql-hackers@arkaria.postgresql.org; Wed, 12 Feb 2025 16:02:11 +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 1tiFBi-00AUVi-Qr for pgsql-hackers@lists.postgresql.org; Wed, 12 Feb 2025 16:02:11 +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 1tiFBh-000R9I-2A for pgsql-hackers@postgresql.org; Wed, 12 Feb 2025 16:02:10 +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 51CG24le3337508; Wed, 12 Feb 2025 11:02:04 -0500 From: Tom Lane To: Andres Freund cc: Euler Taveira , "ranier.vf@gmail.com" , pgsql-hackers Subject: Re: Small memory fixes for pg_createsubcriber In-reply-to: References: <68d6d810-4ef1-4f62-b47f-89b21501249b@app.fastmail.com> Comments: In-reply-to Andres Freund message dated "Wed, 12 Feb 2025 09:34:24 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3337506.1739376124.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 12 Feb 2025 11:02:04 -0500 Message-ID: <3337507.1739376124@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Andres Freund writes: > On 2025-02-11 13:32:32 -0300, Euler Taveira wrote: >> There is no bug. They are the same behind the scenes. > That *is* a bug. On windows the allocator that a shared library (i.e. li= bpq) > uses, may *not* be the same as the one that an executable > (i.e. pg_createsubscriber). It's not correct to free memory allocated i= n a > shared library just with free, it has to go through the library's free. Indeed. This is particularly pernicious because it will work even on Windows under common scenarios (which no doubt explains the lack of field reports). From the last time we discussed this [1]: It seems to work fine as long as a debug-readline is paired with a debug-psql or a release-readline is paired with a release-psql. I wish we had some way to detect misuses automatically ... This seems like the sort of bug that Coverity could detect if only it knew to look, but I have no idea if it could be configured that way. Maybe some weird lashup with a debugging malloc library would be another way. regards, tom lane [1] https://www.postgresql.org/message-id/20240709225934.746y5fg3kgxkyant@= awork3.anarazel.de