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

Re: [PATCH] Fix handle leak in builtin-pack-objects

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Nov 19, 2008, 11:54 UTC
Message-ID
<4923FE58.3090503@viscovery.net>
In-Reply-To
<81b0412b0811190313p643c0cb4vad620ea942aeea93@mail.gmail.com>
Alex Riesen schrieb:
> The opened packs seem to stay open forever.

In my MinGW port I have the patch below that avoids that t5303 fails because of a pack file that remains open. (Open files cannot be replaced on Windows.) I had hoped that your patch would help, but it does not. Something else still keeps the pack file open. Can anything be done about that?

-- Hannes
From: Johannes Sixt <j6t@kdbg.org>
Date: Mon, 17 Nov 2008 09:25:19 +0100
Subject: [PATCH] t5303: Do not overwrite an existing pack

This test corrupts a pack file, then repacks the objects. The consequence is that the repacked pack file has the same name as the original file (that has been corrupted).

During its operation, git-pack-objects opens the corrupted file and keeps it open at all times. On Windows, this is a problem because a file that is open in any process cannot be delete or replaced, but that is what we do in some of the test cases, and so they fail.

The work-around is to write the repacked objects to a file of a different name, and replace the original after git-pack-objects has terminated.

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
---
 t/t5303-pack-corruption-resilience.sh |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/t/t5303-pack-corruption-resilience.sh
b/t/t5303-pack-corruption-resilience.sh
index 5132d41..41c83e3 100755
--- a/t/t5303-pack-corruption-resilience.sh
+++ b/t/t5303-pack-corruption-resilience.sh
@@ -43,8 +43,11 @@ create_new_pack() {

 do_repack() {
     pack=`printf "$blob_1\n$blob_2\n$blob_3\n" |
-          git pack-objects $@ .git/objects/pack/pack` &&
-    pack=".git/objects/pack/pack-${pack}"
+          git pack-objects $@ .git/objects/pack/packtmp` &&
+    packtmp=".git/objects/pack/packtmp-${pack}" &&
+    pack=".git/objects/pack/pack-${pack}" &&
+    mv "${packtmp}.pack" "${pack}.pack" &&
+    mv "${packtmp}.idx" "${pack}.idx"
 }

 do_corrupt_object() {
-- 
1.6.0.4.1683.g35125
Previous: Alex RiesenNext: Alex Riesen
Message 2 of 23 in “Fix handle leak in builtin-pack-objects”
  1. Fix handle leak in builtin-pack-objectsAlex Riesen, Nov 19, 2008
  2. Johannes SixtNov 19, 2008
  3. Alex RiesenNov 19, 2008
  4. Johannes SixtNov 19, 2008
  5. Nicolas PitreNov 19, 2008
  6. Johannes SixtNov 19, 2008
  7. Nicolas PitreNov 19, 2008
  8. Alex RiesenNov 19, 2008
  9. Johannes SixtNov 19, 2008
  10. Alex RiesenNov 19, 2008
  11. Nicolas PitreNov 19, 2008
  12. Johannes SixtNov 19, 2008
  13. compat/mingw.c: Teach mingw_rename() to replace read-only filesJohannes Sixt, Nov 19, 2008
  14. Alex RiesenNov 26, 2008
  15. Nicolas PitreNov 26, 2008
  16. Alex RiesenNov 26, 2008
  17. make sure packs to be replaced are closed beforehandNicolas Pitre, Dec 9, 2008
  18. Alex RiesenDec 9, 2008
  19. Johannes SixtDec 10, 2008
  20. Junio C HamanoDec 10, 2008
  21. Alex RiesenDec 10, 2008
  22. Nicolas PitreNov 19, 2008
  23. Alex RiesenNov 19, 2008

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.