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

Re: fatal: Out of memory, getdelim failed under NFS mounts

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 10, 2017, 18:56 UTC
Message-ID
<xmqqzib72qvs.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<8e307474-d180-6d98-2c6b-062f2181bd14@web.de>
René Scharfe <l.s.r@web.de> writes:
Show 16 quoted lines
> I doubt the type of file system matters.  The questions are: How much
> main memory do you have, what is git trying to cram into it, is there
> a way to reduce the memory footprint or do you need to add more RAM?
>
>> any recommendations on how to pin point the "offender"? ;)
> Running "GIT_TRACE=1 git pull --ff-only origin master" would be a
> good start, I think, to find out which of the different activities
> that pull is doing causes the out-of-memory error.
>
> "free" and "ulimit -a" can help you find out how much memory you can
> use.
>
> Also: What does "wc -L .git/FETCH_HEAD .git/packed-refs" report?
> getdelim() is used mostly to read lines from files like these and in
> the admittedly unlikely case that they are *really* long such an
> error would be expected.

There is only one getdelim() call, which was introduced in v2.5.0 timeframe, and it is used like this:

	r = getdelim(&sb->buf, &sb->alloc, term, fp);
	if (r > 0) {
		sb->len = r;
		return 0;
	}
	assert(r == -1);
	/*
	 * Normally we would have called xrealloc, which will try to free
	 * memory and recover. But we have no way to tell getdelim() to do so.
	 * Worse, we cannot try to recover ENOMEM ourselves, because we have
	 * no idea how many bytes were read by getdelim.
	 *
	 * Dying here is reasonable. It mirrors what xrealloc would do on
	 * catastrophic memory failure. We skip the opportunity to free pack
	 * memory and retry, but that's unlikely to help for a malloc small
	 * enough to hold a single line of input, anyway.
	 */
	if (errno == ENOMEM)
		die("Out of memory, getdelim failed");

So the function is returning -1 and leaving ENOMEM in errno on Yaroslav's system.

I wonder if we are truly hitting out of memory, though. The same symptom could bee seen if getdelim() does not touch errno when it returns -1, but some other system call earlier set it to ENOMEM, for example.

If the same version of Git is recompiled there without HAVE_GETDELIM defined, would it still die with out of memory (presumably inside the call to strbuf_grow() in the strbuf_getwholeline() function)?

Previous: René ScharfeNext: Yaroslav Halchenko
Message 5 of 21 in “fatal: Out of memory, getdelim failed under NFS mounts”
  1. Yaroslav HalchenkoAug 9, 2017
  2. René ScharfeAug 10, 2017
  3. Yaroslav HalchenkoAug 10, 2017
  4. René ScharfeAug 10, 2017
  5. Junio C HamanoAug 10, 2017
  6. Yaroslav HalchenkoAug 10, 2017
  7. René ScharfeAug 10, 2017
  8. Jeff KingAug 10, 2017
  9. Yaroslav HalchenkoAug 10, 2017
  10. strbuf: clear errno before calling getdelim(3)René Scharfe, Aug 10, 2017
  11. Jeff KingAug 10, 2017
  12. Yaroslav HalchenkoAug 10, 2017
  13. Junio C HamanoAug 10, 2017
  14. Simon RuderichAug 11, 2017
  15. René ScharfeAug 11, 2017
  16. Simon RuderichAug 12, 2017
  17. René ScharfeAug 12, 2017
  18. René ScharfeAug 12, 2017
  19. Jeff KingAug 13, 2017
  20. René ScharfeAug 13, 2017
  21. Jeff KingAug 13, 2017

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.