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 1tcrpC-003IbX-2Q for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Jan 2025 20:04:42 +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 1tcrpA-00369e-MZ for pgsql-bugs@arkaria.postgresql.org; Tue, 28 Jan 2025 20:04:40 +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 1tcrpA-00369W-ER for pgsql-bugs@lists.postgresql.org; Tue, 28 Jan 2025 20:04:40 +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 1tcrp8-002073-18 for pgsql-bugs@lists.postgresql.org; Tue, 28 Jan 2025 20:04:39 +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 50SK4Zup1414970; Tue, 28 Jan 2025 15:04:35 -0500 From: Tom Lane To: Andres Freund cc: dan-eli@mail.ru, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later In-reply-to: References: <18785-916b89e64ced06e1@postgresql.org> Comments: In-reply-to Andres Freund message dated "Tue, 28 Jan 2025 14:55:38 -0500" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1414968.1738094675.1@sss.pgh.pa.us> Date: Tue, 28 Jan 2025 15:04:35 -0500 Message-ID: <1414969.1738094675@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-01-28 13:58:13 +0000, PG Bug reporting form wrote: >> Hello, I suggest the following patch for this issue. >> >> @@ -905,6 +905,8 @@ ExtendBufferedRelTo(BufferManagerRelation bmr, >> bmr.smgr->smgr_cached_nblocks[fork] == InvalidBlockNumber) >> && >> !smgrexists(bmr.smgr, fork)) >> { >> + >> + Assert(bmr.rel != NULL); >> LockRelationForExtension(bmr.rel, ExclusiveLock); > I guess it couldn't hurt to add them. It's fine for existing callers... Seems quite pointless really. If bmr.rel is NULL, the LockRelationForExtension call will SIGSEGV all by itself. Transforming that into a SIGABRT isn't moving the football much. The actually interesting question is whether it's possible to reach there with bmr.rel being NULL, and if so what we have to do to avoid such a crash. Adding an Assert still doesn't help. regards, tom lane