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

[PATCH] test_bitmap_hashes(): handle repository without bitmaps

From
Jeff King <peff@peff.net>
Date
Nov 5, 2021, 09:01 UTC
Message-ID
<YYTy6+DG5guzJIO7@coredump.intra.peff.net>

If prepare_bitmap_git() returns NULL (one easy-to-trigger cause being that the repository does not have bitmaps at all), then we'll segfault accessing bitmap_git->hashes:

  $ t/helper/test-tool bitmap dump-hashes
  Segmentation fault

We should treat this the same as a repository with bitmaps but no name-hashes, and quietly produce an empty output. The later call to free_bitmap_index() in the cleanup label is OK, as it treats a NULL pointer as a noop.

This isn't a big deal in practice, as this function is intended for and used only by test-tool. It's probably worth fixing to avoid confusion, but not worth adding coverage for this to the test suite.

Signed-off-by: Jeff King <peff@peff.net>
---
This is new in the v2.34.0 cycle, but it's so low impact it doesn't
matter much if we ship with the bug. OTOH, it's pretty low-risk since it
is only run by the test suite.
 pack-bitmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pack-bitmap.c b/pack-bitmap.c
index a56ceb9441..f772d3cb7f 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1759,7 +1759,7 @@ int test_bitmap_hashes(struct repository *r)
 	struct object_id oid;
 	uint32_t i, index_pos;
 
-	if (!bitmap_git->hashes)
+	if (!bitmap_git || !bitmap_git->hashes)
 		goto cleanup;
 
 	for (i = 0; i < bitmap_num_objects(bitmap_git); i++) {
-- 
2.34.0.rc1.634.g85d556ea55
Next: Junio C Hamano
Message 1 of 9 in “test_bitmap_hashes(): handle repository without bitmaps”
  1. test_bitmap_hashes(): handle repository without bitmapsJeff King, Nov 5, 2021
  2. Junio C HamanoNov 5, 2021
  3. Taylor BlauNov 5, 2021
  4. Jeff KingNov 5, 2021
  5. move some test-tools to 'unstable plumbing' built-ins (was: [PATCH] test_bitmap_hashes(): handle repository without bitmaps)Ævar Arnfjörð Bjarmason, Nov 6, 2021
  6. Taylor BlauNov 7, 2021
  7. Junio C HamanoNov 8, 2021
  8. Ævar Arnfjörð BjarmasonNov 8, 2021
  9. Taylor BlauNov 8, 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.