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

Re: What's cooking in git.git (Oct 2013, #03; Wed, 16)

From
Karsten Blees <karsten.blees@gmail.com>
Date
Oct 22, 2013, 13:13 UTC
Message-ID
<526679F2.4060701@gmail.com>
In-Reply-To
<xmqqfvrywg4y.fsf@gitster.dls.corp.google.com>
Am 18.10.2013 21:09, schrieb Junio C Hamano:
Show 19 quoted lines
> Karsten Blees <karsten.blees@gmail.com> writes:
> 
>> The coredumps are caused by my patch #10, which free()s
>> cache_entries when they are removed, in combination with ...
> 
> Looking at that patch, it makes me wonder if remove_index_entry_at()
> and replace_index_entry() should be the ones that frees the old
> entry in the first place.  A caller may already have a ce pointing
> at an old entry and use the information from old_ce to update a new
> one after it installed it, e.g.
> 
> 	old_ce = ...
>         new_ce = make_cache_entry(... old_ce->name, ...);
>         replace_index_entry(... new_ce);
> 	new_ce->ce_mode = old_ce->cd_mode;
> 	free(old_ce);
> 
> The same goes for the functions that remove the entry.
> 
Moving free() to the callers or caller's callers would make it much more complicated (more places to change). Besides, most callers don't even have a reference to old_ce and simply remove by position. Of course, this doesn't prevent caller's caller's callers to keep a reference to a removed / replaced entry, as found by Thomas.
Show 6 quoted lines
> 
> Going forward, I do agree with your patch #10 that removal or
> replacing that may make an existing entry unreferenced should free
> entries that are no longer used, and "use after free" should be
> forbidden.
> 
OK, I'll spend some more time analyzing the call hierarchies to see if there are more uses of removed cache_entries. I'll try to post an updated v4 by the end of the week.
Karsten
Previous: Jens LehmannNext: Jens Lehmann
Message 9 of 10 in “What's cooking in git.git (Oct 2013, #03; Wed, 16)”
  1. Junio C HamanoOct 16, 2013
  2. Karsten BleesOct 17, 2013
  3. Junio C HamanoOct 17, 2013
  4. Junio C HamanoOct 17, 2013
  5. Karsten BleesOct 18, 2013
  6. Junio C HamanoOct 18, 2013
  7. Jens LehmannOct 18, 2013
  8. submodule: don't access the .gitmodules cache entry after removing itJens Lehmann, Oct 18, 2013
  9. Karsten BleesOct 22, 2013
  10. Jens LehmannOct 18, 2013

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.