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

Re: [PATCH] fast-import: avoid running end_packfile recursively

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 10, 2015, 18:45 UTC
Message-ID
<xmqqa90lwqpr.fsf@gitster.dls.corp.google.com>
In-Reply-To
<20150210010719.GA31823@peff.net>
Jeff King <peff@peff.net> writes:
Show 12 quoted lines
> When an import has finished, we run end_packfile() to
> finalize the data and move the packfile into place. If this
> process fails, we call die() and end up in our die_nicely()
> handler.  Which unfortunately includes running end_packfile
> to save any progress we made. We enter the function again,
> and start operating on the pack_data struct while it is in
> an inconsistent state, leading to a segfault.
> ... This new problem is
> quite similar, except that we are worried about calling
> die() _during_ end_packfile, not right after. Ideally we
> would simply set pack_data to NULL as soon as we enter the
> function, and operate on a copy of the pointer.
Nicely analyzed and well done.
Show 5 quoted lines
> Unfortunately, it is not so easy. pack_data is a global, and
> end_packfile calls into other functions which operate on the
> global directly. We would have to teach each of these to
> take an argument, and there is no guarantee that we would
> catch all of the spots.

Well, you can rename the global to something else to make sure ;-) But I think that the approach with a simple flag is better.

If we were planning to do the global-to-parameter surgery for other reasons (perhaps need to make things reentrant?) then the equation might become different, but I do not think we are doing that right now, so...

Thanks.
Previous: Jeff KingNext: Jeff King
Message 2 of 3 in “fast-import: avoid running end_packfile recursively”
  1. fast-import: avoid running end_packfile recursivelyJeff King, Feb 10, 2015
  2. Junio C HamanoFeb 10, 2015
  3. Jeff KingFeb 10, 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.