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

Re: [PATCH 1/3] ref-filter: free memory from used_atom

From
Jeff King <peff@peff.net>
Date
Oct 18, 2018, 06:33 UTC
Message-ID
<20181018063306.GA23497@sigill.intra.peff.net>
In-Reply-To
<xmqqa7njevu2.fsf@gitster-ct.c.googlers.com>
On Fri, Oct 12, 2018 at 11:35:01AM +0900, Junio C Hamano wrote:
Show 7 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
> 
> > Olga Telezhnaya <olyatelezhnaya@gmail.com> writes:
> 
> These three patches seem to cause t6300 to fail with an attempt to
> free an invalid pointer in "git for-each-ref --format='%(push)'"
> (6300.25)

I dug into this a bit. I think it's actually a misapplication of the patches on your side. Applying them locally works, but your ot/ref-filter-plug-leaks branch does not.

The patch below on top of your branch helps. :)
diff --git a/ref-filter.c b/ref-filter.c
index f4ff80eca0..4255de1d75 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1567,7 +1567,6 @@ static int populate_value(struct ref_array_item *ref, struct strbuf *err)
 					continue;
 			}
 			free((char *)v->s); /* we will definitely re-init it on the next line */
-			free((char *)v->s);
 			fill_remote_ref_details(atom, refname, branch, &v->s);
 			continue;
 		} else if (starts_with(name, "color:")) {

Presumably it came from the manual comment-style fixup.

With that fix, the tests run fine for me under ASan/UBSan (with the
exception of t5310, but that's fixed already in a parallel topic).

-Peff
Previous: Junio C HamanoNext: Junio C Hamano
Message 9 of 11 in “ref-filter: free memory from used_atom”
  1. 1/3 ref-filter: free memory from used_atomOlga Telezhnaya, Oct 9, 2018
  2. 2/3 ls-remote: release memory instead of UNLEAKOlga Telezhnaya, Oct 9, 2018
  3. Junio C HamanoOct 11, 2018
  4. 3/3 ref-filter: free item->value and item->value->sOlga Telezhnaya, Oct 9, 2018
  5. Junio C HamanoOct 11, 2018
  6. Jeff KingOct 12, 2018
  7. Junio C HamanoOct 11, 2018
  8. Junio C HamanoOct 12, 2018
  9. Jeff KingOct 18, 2018
  10. Junio C HamanoOct 18, 2018
  11. Оля ТележнаяOct 18, 2018

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.