Re: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later
Date
Msg-id 1414969.1738094675@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later  (Andres Freund <andres@anarazel.de>)
Responses Re: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later
List pgsql-bugs
Andres Freund <andres@anarazel.de> 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



pgsql-bugs by date:

Previous
From: Andres Freund
Date:
Subject: Re: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later
Next
From: Andres Freund
Date:
Subject: Re: BUG #18785: Pointer bmr.rel, dereferenced by passing as 1st parameter to function is checked for NULL later