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

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

From
Alex Riesen <raa.lkml@gmail.com>
Date
Nov 19, 2008, 14:17 UTC
Message-ID
<81b0412b0811190617t4a9df151m886700672a21fad8@mail.gmail.com>
In-Reply-To
<49241AEF.1080808@viscovery.net>
2008/11/19 Johannes Sixt <j.sixt@viscovery.net>:
Show 25 quoted lines
> Alex Riesen schrieb:
>> 2008/11/19 Nicolas Pitre <nico@cam.org>:
>>> On Wed, 19 Nov 2008, Johannes Sixt wrote:
>>>> 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>
>>> Acked-by: Nicolas Pitre <nico@cam.org>
>>
>> Are you sure? Will it work in a real repository? Were noone does
>> rename the previous pack files into packtmp-something?
>
> Oh, the patch only works around the failure in the test case. In a real
> repository there is usually no problem because the destination pack file
> does not exist.
>
> The unusual case is where you do this:
>
>  $ git rev-list -10 HEAD | git pack-objects foobar
>
> twice in a row: In this case the second invocation fails on Windows
> because the destination pack file already exists *and* is open. But not
> even git-repack does this even if it is called twice. OTOH, the test case
> *does* exactly this.
>
Still bad...

BTW, the patch _does_ fix the "unusual case" for me. IOW, I plainly copied your rev-list|pack-objects into command line. As expected, it fails for Junio's master (after the second run) and works with the patch:

  $ git rev-list -10 HEAD | ./git pack-objects .git/objects/pack/foobar
  Counting objects: 10, done.
  Compressing objects: 100% (9/9), done.
  82864ec14cd06e6089543a1419762e4cd40f7988
  Writing objects: 100% (10/10), done.
  Total 10 (delta 1), reused 10 (delta 1)
  $ git rev-list -10 HEAD | ./git pack-objects .git/objects/pack/foobar
  Counting objects: 10, done.
  Compressing objects: 100% (9/9), done.
  fatal: unable to rename temporary pack file: Permission denied
  $ git cherry-pick fix-fd-leak
  Finished one cherry-pick.
  [master]: created e629465: "Fix handle leak in builtin-pack-objects"
   1 files changed, 1 insertions(+), 0 deletions(-)
  $ git rev-list -10 HEAD | ./git pack-objects .git/objects/pack/foobar
  Counting objects: 10, done.
  Compressing objects: 100% (9/9), done.
  0e43d919a2a8336fd740d8d9b8f9f78d49e855e5
  Writing objects: 100% (10/10), done.
  Total 10 (delta 1), reused 9 (delta 1)
  $ git rev-list -10 HEAD | ./git pack-objects .git/objects/pack/foobar
  Counting objects: 10, done.
  Compressing objects: 100% (9/9), done.
  0e43d919a2a8336fd740d8d9b8f9f78d49e855e5
  Writing objects: 100% (10/10), done.
  Total 10 (delta 1), reused 10 (delta 1)
  $ git rev-list -10 HEAD | ./git pack-objects .git/objects/pack/foobar
  Counting objects: 10, done.
  Compressing objects: 100% (9/9), done.
  0e43d919a2a8336fd740d8d9b8f9f78d49e855e5
  Writing objects: 100% (10/10), done.
  Total 10 (delta 1), reused 10 (delta 1)
Previous: Johannes SixtNext: Nicolas Pitre
Message 10 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.