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

[PATCH v2 1/2] pack-bitmap: clean up include_check after use

From
Jeff King <peff@peff.net>
Date
Apr 28, 2021, 15:42 UTC
Message-ID
<YImCZpLA0TjAkU9/@coredump.intra.peff.net>
In-Reply-To
<YImCNXC5DUvy5gT8@coredump.intra.peff.net>

When a bitmap walk has to traverse (to fill in non-bitmapped objects), we use rev_info's include_check mechanism to let us stop the traversal early. But after setting the function and its data parameter, we never clean it up. This means that if the rev_info is used for a subsequent traversal without bitmaps, it will unexpectedly call into our include_check function (worse, it will do so pointing to a now-defunct stack variable in include_check_data, likely resulting in a segfault).

There's no code which does this now, but it's an accident waiting to happen. Let's clean up after ourselves in the bitmap code.

Reported-by: David Emett <dave@sp4m.net>
Signed-off-by: Jeff King <peff@peff.net>
---
 pack-bitmap.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 3ed15431cd..f2b59fbf48 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -631,6 +631,9 @@ static struct bitmap *find_objects(struct bitmap_index *bitmap_git,
 		traverse_commit_list_filtered(filter, revs,
 					      show_commit, show_object,
 					      &show_data, NULL);
+
+		revs->include_check = NULL;
+		revs->include_check_data = NULL;
 	}
 
 	return base;
-- 
2.31.1.791.g8400859cdc
Previous: Jeff KingNext: Jeff King
Message 8 of 10 in “Two issues with mark_reachable_objects”
  1. David EmettApr 27, 2021
  2. Jeff KingApr 27, 2021
  3. Jeff KingApr 27, 2021
  4. prune: save reachable-from-recent objects with bitmapsJeff King, Apr 27, 2021
  5. David EmettApr 28, 2021
  6. Jeff KingApr 28, 2021
  7. 0/2 prune: save reachable-from-recent objects with bitmapsJeff King, Apr 28, 2021
  8. 1/2 pack-bitmap: clean up include_check after useJeff King, Apr 28, 2021
  9. 2/2 prune: save reachable-from-recent objects with bitmapsJeff King, Apr 28, 2021
  10. Junio C HamanoApr 29, 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.