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 1wtD9r-0013oh-0L for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Aug 2026 23:42:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wtD9o-00EKlj-2I for pgsql-bugs@arkaria.postgresql.org; Sun, 09 Aug 2026 23:42:20 +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 1wtD9n-00EKlQ-2g for pgsql-bugs@lists.postgresql.org; Sun, 09 Aug 2026 23:42:19 +0000 Received: from fout-b3-smtp.messagingengine.com ([202.12.124.146]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wtD9i-00000001FFj-465e for pgsql-bugs@lists.postgresql.org; Sun, 09 Aug 2026 23:42:17 +0000 Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfout.stl.internal (Postfix) with ESMTP id 6D0911D00180; Sun, 9 Aug 2026 19:42:12 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Sun, 09 Aug 2026 19:42:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; 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=fm3; t=1786318932; x=1786405332; bh=w+4ZfpzgRR 109HRytk3WXE6CcG83lA8ZrNpD3brDSMo=; b=NOsNoKYKU251nMUZADkxzZ5w4x wKBPxbfDFR9T3y0l6zZFT6u+EpBXbU5vcW09918xNiZzch+zRaunS9EdFYHe/7sC oeemox1qejWbjtSE2dGlxrVVOzje2uWjQPw6IGPYWaacFGXrxnGNhB9IP99HoRRc zM4BDkSfbNUkrm6Gq2EaK6M/Oy2dv7F3/lNl4BJxDjh6HSaKaCf4L3t1ljxB4euE am4Sjk/2+EqJuIJcT1hQX3p+UzxXQpfVv/82zSVlck9xHtt6+aSBvwJmLkoi6FdZ WSI8ciLMY0modpGLZdIlDxt7nG/Nb6rm4b06ozu8hqwldMb3h2gX6qNS4AQQ== 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= 1786318932; x=1786405332; bh=w+4ZfpzgRR109HRytk3WXE6CcG83lA8ZrNp D3brDSMo=; b=cbaAxAQ+FpMbIxo4eA5KdPkEJv10D1ybOyYqh/og294msW1Tr5l lLvYgA1CbiClbB1D1Cx7eoP36NwsshxOGBQMAlWU5XcBwX+jkqrj2+KA8N25aB/D buzo2mevziiur13CGCE1L5/a2cMsYbP9ZXwVJZzSSVn6oOhvpjTBJiznV8AKDZUa tLyLvqxgpauGxDnBGLRv/H4/BiIGTjSeSKCdhafRnSd0GqkufjdakcNWefIWGREB RMKnQVwfDTrU1W0TyXnbkObKbGyYNk7miEfSp1+sHH4oSX60dqg8Kf0Sq11MsDWS 3KT3VZfgGNfHsHuPc0qPCtclCWXSzQHu/5w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTGwzakQs7KZiV1ainQw9a1HRwwNagIWFHr6PPtVkrGJc890mrViSPzqYaTdZjdCUO rkGrwTpuXE9ctE59yZCV7xr0WlZfVHSlAN2VBVLQxxMpB+zuG/cRvHEPuCBcEKNuL7S3lO G4sjDTSKqhLmb5OZFuNrI8sfdJKcutsH0k5r8InBdzDrc0Hzfq4hEoCNHOfdd9Js+LuwDh 1g0A2hyYt7fQ1QTRfUG23D298RmwQInMrOAilunfpPubfk1PXItk8Ng7Vqf/A1C7cUl+dM dcprrvJzdyZJlNJPU3WiwqL/xrYvqbmsiwPbcrbya7Z7aURXm/OYmXb8BkGEQmd1ago8qm KQPKmZthVM9G0hVfON9FVAIVycnacQMLGL115EzgA5WKbOkDLccCXH8JV7p9usdds6buVC OorI2qpixE3enKsdI4cCoUZ3ts2OA0u8/l4suK+DOInnwvRDIZP1s0bXdaAG22DKXC4D2G lp7zaNKnTYgu/tj8edBzgz1mtmJ0t6LdaG6G3CUG6R58kxzEySfSCWGiPwZ1yL/bwnqY+u w0URqSr46Njs6Vkd7Pa1dbJI87qjBH8EPxQPJ+kYLm3l5xG9BFMc83nwTup385VFYMYJnS lQCAo/fteDyU4/TAZ7weV2OsAuZ8QNAXTeOGGU2NF9FxRLqfHWvWb8VZbAIw X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 9 Aug 2026 19:42:10 -0400 (EDT) Date: Mon, 10 Aug 2026 08:42:06 +0900 From: Michael Paquier To: Niall Newman Cc: pgsql-bugs@lists.postgresql.org Subject: Re: PostgreSQL 18.4 backend SIGSEGV in pgstat_gc_entry_refs() after caught DSM attach error Message-ID: References: <2FDAA194-9CF3-4FD7-A450-F1A4BEB125F6@turacolabs.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="KB9QQpTSIaf40ku/" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --KB9QQpTSIaf40ku/ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Aug 07, 2026 at 03:34:38PM +0900, Michael Paquier wrote: > 5) While on it, I think that we could do something about the > dshash_find_or_insert() in pgstat_get_entry_ref(), where we could > clean up the local reference if dshash_find_or_insert() returns NULL. > That's content only worth on HEAD, as the problem is unlikely going to > happen in practice, and that's only a local reference. >=20 > To summarize, I have fixed 2) with 4069df21beb8 backpatched down to > v15, and did bf80a4c2d238 for 1) on HEAD. 3) is not necessary. 4) > should have its own discussion, as it's a broader change impacting > anything that uses DSA/DSM. And I am planning to apply the attached > for 5) only on HEAD as a follow-up improvement. A consequence of 5) that I have missed during my initial lookup is that it could be possible to finish with a NULL pointer dereference if a concurrent backend has the idea to bump the refcount of the entry that has a stale NULL shared_entry (due to entry reinit, for one, or even a drop/create). A OOM-ed backend calling pgstat_gc_entry_refs() would be in trouble. It's the first time I've heard about dshash_find_or_insert_extended(). That's kind of nice, perhaps it would make sense to extend its use in other areas of the code.. -- Michael --KB9QQpTSIaf40ku/ Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmp5EE4ACgkQnvQgOdby QH2JPw/+OZDjmC7PTfWUkb07WpSDs8yDrE1MZYurLMdl2T+kiSLP9xlm3XxBIAVy ji4PSPJw35UtjlmUWHa2JOzOGxWGdopizoU4ISBFHwb6pmlIKb1hj2oXXTtfeDXR wDUJZglAiAar9UiKgl7MVV9NFcgMb8gsG8XMtkeILuS4nQeWg6XS4GPmq6jcKcD2 qeDIed6nMGQsjlX/p1Nrw9PMu8F/4tRLia2m88Ige5buolHLXXNZujJ9J5uue0XZ IFOe3pfIu+VVX3I8gSbvSle3lnBCZpghr3ACUUVuwsjg62ukZdHKLiOQXQqnX5Sq qT0L6MbcoOaBEsUrFYsoX6WjK1QJ0gnw7z7Suil/B2785UTPw04c0F75zZWdSiUS rTRLB08mmmgfOxvOe7dbt7sIcWo0HBS/iQyHDF7+fP8htx5xAXwROwh7MWmKa4RV l4f/oN17zBHcL0SWDoWOD7gghRwGMhzY8yY3Hpfq/36OvE617sDX9XQJa/+LwUZ+ FtgJjSe3DmDpChumgG7iJgVCzXoPWZU4DfQh4/K3dBm0PUqx/7SWakJXO+aJTwc8 HK8n4QOXqdeyvEnQTArqTAdgtnzGP5RQORs6Y+SpXHXiwgc0+W4tUjnAlTfm0uhZ orUJ1ceUROaqD6VZDr2foa5k0N0WUAy2WDQEzb/VQj2U2Zw7ao4= =jksH -----END PGP SIGNATURE----- --KB9QQpTSIaf40ku/--