git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Fwd: coverity problems in reftable code

From
Han-Wen Nienhuys <hanwen@google.com>
Date
Dec 7, 2021, 11:34 UTC
Message-ID
<CAFQ2z_OrN+RkwnMyrJHdh5xN6ueOP8KKBVQ7-U4kEkA3ApcuNg@mail.gmail.com>
In-Reply-To
<CAFQ2z_OK5949p1WfovJ00Katk5hTv_oeLo-ZRCi1XqrtzQqL2g@mail.gmail.com>
On Sat, Dec 4, 2021 at 3:13 AM Jeff King <peff@peff.net> wrote:
Show 8 quoted lines
> We're not doing project-wide analysis with Coverity right now, but I've
> been doing builds of my personal repo, which I usually build off of
> next. And since hn/reftable just hit next, it got included in my latest
> build.
>
> It came up with several complaints. Some of them are dumb and can be
> ignored (e.g., using rand() in a test harness, oh no!) but I poked at a
> few and they look like real issues:
I fixed most of the obvious ones.
>   - A lot of your structs have vtables. Initializing them to NULL, as in
>     reftable_reader_refs_for_indexed(), leaves the risk that we'll try
>     to call a NULL function pointer, even if it's for something simple

I have the impression that coverity doesn't understand enough of the control flow. Some of the things it complains of are code paths that only get executed if err==0, in which case, the struct members at hand should not be null.

Show 6 quoted lines
> I similarly wondered if these polymorphic types could be using a union
> within reftable_record, rather than pointing to a separate stack
> variable. Then you could initialize the whole thing without worrying
> about intermediate NULLs (and also there's less pointer chasing and it's
> a little bit more type safe than a void pointer). But again, I don't
> know the code well enough to know if that would cover all of your cases.

This is a great idea. I've made a change that does this, which I will post shortly.

> The summary of issues is below. You can get more details on their site.
> I _think_ I've configured it so that anybody can look at:
>
>   https://scan.coverity.com/projects/peff-git/view_defects
Alas, it says I have no access, even after I logged in.
-- 
Han-Wen Nienhuys - Google Munich
I work 80%. Don't expect answers from me on Fridays.
--
Google Germany GmbH, Erika-Mann-Strasse 33, 80636 Munich
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Previous: Jeff KingNext: Ævar Arnfjörð Bjarmason
Message 2 of 7 in “coverity problems in reftable code”
  1. Jeff KingDec 4, 2021
  2. Fwd: coverity problems in reftable codeHan-Wen Nienhuys, Dec 7, 2021
  3. Ævar Arnfjörð BjarmasonDec 7, 2021
  4. Jeff KingDec 8, 2021
  5. Jeff KingDec 8, 2021
  6. Han-Wen NienhuysDec 8, 2021
  7. Jeff KingDec 8, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.