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.96) (envelope-from ) id 1wFbnf-005M6U-0F for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 17:55:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFbnd-00EexM-0n for pgsql-hackers@arkaria.postgresql.org; Wed, 22 Apr 2026 17:55:45 +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.96) (envelope-from ) id 1wFbnb-00Eex7-1q for pgsql-hackers@lists.postgresql.org; Wed, 22 Apr 2026 17:55:44 +0000 Received: from fout-b8-smtp.messagingengine.com ([202.12.124.151]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wFbnY-00000002Vhw-2RZC for pgsql-hackers@postgresql.org; Wed, 22 Apr 2026 17:55:43 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfout.stl.internal (Postfix) with ESMTP id C66C11D00273; Wed, 22 Apr 2026 13:55:37 -0400 (EDT) Received: from phl-frontend-03 ([10.202.2.162]) by phl-compute-01.internal (MEProxy); Wed, 22 Apr 2026 13:55:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding: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=1776880537; x=1776966937; bh=qAzypLc9ag2f/aFBreoLhksTHvVZX//jMlC2XjceiB8=; b= rduEuwAFM/TjwimWmK6a2cXywf+igG9GrBR3ocAZm/Y9dMg2AMl9gx9tWzHIIHdD n49Vj5gcwKg61AJHa1Gq7gqZFsLzM6xNyKipC1ZEGpDG68xAZxTTduPjwvP2qRMS /3JFdp0oCpirl49/YcUlt0ZdMQDtE0X81bkZTS6nt9p+4HeZ+WEaMKbxdTpFaSyf 2Zh0mrDq7nbVIiZyyla1caVouL2BCP+D6uTNYBJVYiO8DiIv27Ha9MNe+DP3/37/ iKVkK4pulDu2+W1+kvJ3xAukOMTVWQggrM/cYZm3IRo5AGrKOO4AXgjG43fpEIHt 2n+9h1tXNOQAv8OozDpHQw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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=fm2; t=1776880537; x= 1776966937; bh=qAzypLc9ag2f/aFBreoLhksTHvVZX//jMlC2XjceiB8=; b=J kbvJTfr6bVCtkQgFavFfWmTiAQ4AKddXmWOeZoNWSV1+TOwsWUQ3IIKkIxNcuo+W x5ucY08mOd3V0qUv2i2CthcgHsDQt5FPWwSQsRjhvIsmTnfAnP17UFfWWYCs4mOr DGJLXcfZC41F3p7Sjb9p/9G3CRaOO/JhR+Cy41galy8kWAr8579If/Vd/Mvq+3La IiKPVclXgPiIFg16iF2tKqtlphcYRH7KOW3VEjnu5cbyWVmL91yk4g2ILresHCet uMs/ZNEjlBivM5Nka0KG30rs/XsMyov73pyqTSOzPv/ISzF03/24cGWbAqOkF8kW NpwZhXTDGo88wvWbZALkw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefhedrtddtgdeigeelvdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpuffrtefokffrpgfnqfghnecuuegr ihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjug hrpeffhffvvefukfhfgggtugfgjgestheksfdttddtjeenucfhrhhomheptehnughrvghs ucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrfgrth htvghrnheptdelledvgfejvdffieeukeefueelfffhgeffhffgffekveeuheeihefhiefg hfdvnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hnughrvghssegrnhgrrhgriigvlhdruggvpdhnsggprhgtphhtthhopeegpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehhvghnrhhikhestdiggeekrdgukhdprhgtphhtth hopehlihdrvghvrghnrdgthhgrohesghhmrghilhdrtghomhdprhgtphhtthhopehmrghs rghordhfuhhjihhisehgmhgrihhlrdgtohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtg hkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Apr 2026 13:55:36 -0400 (EDT) Date: Wed, 22 Apr 2026 13:55:36 -0400 From: Andres Freund To: Fujii Masao Cc: Chao Li , Henrik TJ , PostgreSQL Hackers Subject: Re: Fix memory leak in postmasterMain Message-ID: References: <3e890874-8204-e1c2-8def-3a02cbad2232@0x48.dk> <1658D50F-A8B3-406A-94ED-FA8C7F9DA90B@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2026-04-23 00:29:29 +0900, Fujii Masao wrote: > On Wed, Apr 22, 2026 at 3:46 PM Chao Li wrote: > > > > From my experience, most of the time the postmaster is started with -D. On Linux and macOS, that path can be quite long, PATH_MAX is often 4096 on many Unix-like systems, and I am not sure about Windows. So I think this leak is worth fixing. > > We can also free()/pfree() userDoption in postgres.c and bootstrap.c? > > Since userDoption typically uses only a small amount of memory, I'm not sure > this patch provides much practical benefit from a memory-leak perspective. I don't think this is a leak at all. We *never* can reach the end of the scope in which userDoption is allocated. We abort() if the end of PostmasterMain() is ever reached. What is the leak here supposed to actually be? > So I don't think it needs to be backpatched to the stable branches. Definitely not. > OTOH, if it helps keep Valgrind quiet for userDoption, I may be ok with > applying it to master. I'm doubtful it makes sense to fix it this way. If we do it, we should actually be a bit more systematic and also free output_config_variable. ISTM those strdup()s should actually be pstrdup()s? I suspect changing that would also silence valgrind. Greetings, Andres Freund