Re: [NBTREE] Possible NULL pointer dereference (backend/access/nbtree/nbutils.c) - Mailing list pgsql-hackers

From Peter Geoghegan
Subject Re: [NBTREE] Possible NULL pointer dereference (backend/access/nbtree/nbutils.c)
Date
Msg-id CAH2-WzkTSCHptFtUUwAbmfgJacSW34ibNBDoPvyb6dLX1Ax+_A@mail.gmail.com
Whole thread Raw
In response to Re: [NBTREE] Possible NULL pointer dereference (backend/access/nbtree/nbutils.c)  (Ranier Vilela <ranier.vf@gmail.com>)
Responses Re: [NBTREE] Possible NULL pointer dereference (backend/access/nbtree/nbutils.c)
List pgsql-hackers
On Wed, Sep 2, 2020 at 3:16 PM Ranier Vilela <ranier.vf@gmail.com> wrote:
> Oh, I'm sorry, I thought that "hard crash" was a bad thing.

I think that you are being sarcastic here, but just in case I'm wrong
I'll clarify what I meant: a good sign that a static analysis tool has
produced a useless complaint is that it appears to prove something far
stronger than you first thought possible. You should look out for
that. This is just a heuristic, but in practice it is a good one.
Perhaps you recall our discussion of a similar false positive in
nbtsplitloc.c; that had a similar feel to it. For example, if your
static analysis tool says that code that has been around for many
years is riddled with bugs, then the problem is almost certainly with
the tool (or with how the tool has been used).

High performance C code very often relies on representational
invariants that may not be readily apparent to a compiler --
especially when dealing with on-disk state. Barring some obvious
problem like a hard crash, you have to do the work of assessing if the
code is correct based on the actual assumptions/context of the code. A
static analysis tool is of very little use if you're not going to put
the work in. I went to a lot of trouble to clearly document the code
in question here (the heap TID stuff in _bt_truncate()) -- did you
even bother to read those comments once?

-- 
Peter Geoghegan



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: proposal - function string_to_table
Next
From: Thomas Munro
Date:
Subject: Re: Two fsync related performance issues?