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

Re: git-commit fatal: Out of memory? mmap failed: Bad file descriptor

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 12, 2008, 01:08 UTC
Message-ID
<7vtzljzw8n.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<47880D18.8030405@nrlssc.navy.mil>
Brandon Casey <casey@nrlssc.navy.mil> writes:
Show 27 quoted lines
> Junio C Hamano wrote:
>> Brandon Casey <casey@nrlssc.navy.mil> writes:
>> 
>>> It's reproduceable for me by amending the commit.
>> 
>> Reliably reproducible?  Can you build with "-O0 -g" and run
>> "commit --amend" under gdb?
>> 
>
> make NO_CURL=1 CFLAGS='-O0 -g'
> Done.
>
> I also moved xmmap into commit.c, and turned the inlined definition
> in git-compat-util.h into a declaration.
>
>
> I set a breakpoint on xmmap(). This is the backtrace on the last entry
> into xmmap() before it die()'ed.
>
> The fstat message at the end is from a call to fstat that I added to
> print out the file size (to compare with mmap length). As you can
> see the fstat also fails with the 'Bad file descriptor' message.
>
> #0  xmmap (start=0x0, length=996168, prot=1, flags=2, fd=6, offset=0)
>     at commit.c:680
> #1  0x080acf30 in use_pack (p=0x8150650, w_cursor=0xffffc0ac, offset=94828, 
>     left=0xffffc06c) at sha1_file.c:748

That's the pack window shuffling code in use_pack(). I presume your additional fstat is inside xmmap(), so if p->pack_fd is already closed when this xmmap() call is made, that would explain the symptom.

	while (packed_git_limit < pack_mapped
		&& unuse_one_window(p, p->pack_fd))
		; /* nothing */
	win->base = xmmap(NULL, win->len,
		PROT_READ, MAP_PRIVATE,
		p->pack_fd, win->offset);

I wonder what's the best way to find out who closes file descriptor #6 without clearing p->pack_fd that still holds #6? My reading of unuse_one_window() is that it tried to avoid closing p->pack_fd, so it may already have been closed when we get to this codepath.

Shawn, does this ring a bell?
Previous: Brandon CaseyNext: Alex Riesen
Message 8 of 39 in “git-commit fatal: Out of memory? mmap failed: Bad file descriptor”
  1. Brandon CaseyJan 11, 2008
  2. Charles BaileyJan 11, 2008
  3. Jeff KingJan 12, 2008
  4. Marco CostalbaJan 11, 2008
  5. Brandon CaseyJan 11, 2008
  6. Junio C HamanoJan 11, 2008
  7. Brandon CaseyJan 12, 2008
  8. Junio C HamanoJan 12, 2008
  9. Alex RiesenJan 12, 2008
  10. Brandon CaseyJan 14, 2008
  11. Brandon CaseyJan 15, 2008
  12. Linus TorvaldsJan 15, 2008
  13. Brandon CaseyJan 15, 2008
  14. Linus TorvaldsJan 15, 2008
  15. Brandon CaseyJan 15, 2008
  16. Linus TorvaldsJan 15, 2008
  17. Brandon CaseyJan 15, 2008
  18. Kristian HøgsbergJan 15, 2008
  19. Brandon CaseyJan 15, 2008
  20. Brandon CaseyJan 15, 2008
  21. Linus TorvaldsJan 15, 2008
  22. Linus TorvaldsJan 15, 2008
  23. Junio C HamanoJan 15, 2008
  24. Junio C HamanoJan 16, 2008
  25. Brandon CaseyJan 16, 2008
  26. 1/2 Document lockfile APIJunio C Hamano, Jan 16, 2008
  27. 2/2 close_lock_file(): new function in the lockfile APIJunio C Hamano, Jan 16, 2008
  28. Linus TorvaldsJan 16, 2008
  29. Junio C HamanoJan 16, 2008
  30. Brandon CaseyJan 16, 2008
  31. Junio C HamanoJan 16, 2008
  32. Brandon CaseyJan 16, 2008
  33. Junio C HamanoJan 16, 2008
  34. Brandon CaseyJan 16, 2008
  35. Brandon CaseyJan 16, 2008
  36. Junio C HamanoJan 16, 2008
  37. Brandon CaseyJan 16, 2008
  38. Johannes SixtJan 16, 2008
  39. Junio C HamanoJan 15, 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.