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

Re: [PATCH] add_submodule_odb: initialize alt_odb list earlier

From
Jeff King <peff@peff.net>
Date
Oct 28, 2015, 17:27 UTC
Message-ID
<20151028172758.GA21851@sigill.intra.peff.net>
In-Reply-To
<xmqqa8r3m2xq.fsf@gitster.mtv.corp.google.com>
On Wed, Oct 28, 2015 at 08:24:17AM -0700, Junio C Hamano wrote:
Show 10 quoted lines
> > Note that we can remove the prepare_alt_odb call from the
> > end. It is guaranteed to be a noop, since we will have
> > called it earlier.
> 
> Thanks for a quick and detailed diagnosis and a fix.
> 
> The removal is correct, but even without this fix, the order of
> calls in the original should have screamed "bug" loudly at us, I
> think.  We shouldn't be reading data from alternates file without
> first preparing the place we read data into.

Yeah, I agree. I spent a long time trying to figure out if that prepare_alt_odb was actually doing something useful (like if it was needed to somehow "cement" the new alt into place).

But I don't think it was.

In the majority of cases, it was a noop (we had already prepared when we looked up the first object). But for other cases...

  - if read_info_alternates actually did something, we segfaulted (i.e.,
    this bug)
  - otherwise, we would prepare on _top_ of what we just added to the
    list, which was probably buggy (I didn't dig far enough to see if
    prepare_alt_odb() would overwrite what we just added to the list).
So some pretty dark corners of the code. :)
-Peff
Previous: Junio C Hamano
Message 7 of 7 in “Bug: Segfault when doing "git diff"”
  1. Mathias L. BaumannOct 28, 2015
  2. Victor LeschukOct 28, 2015
  3. Mathias L. BaumannOct 28, 2015
  4. Victor LeschukOct 28, 2015
  5. add_submodule_odb: initialize alt_odb list earlierJeff King, Oct 28, 2015
  6. Junio C HamanoOct 28, 2015
  7. Jeff KingOct 28, 2015

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.