Package: git
Version: 1:2.14.0-1
Severity: important
Tags: upstream patch

Dear git maintainers,

For a while this issue was haunting us in various deployments, in particular 
- on NFS mounts
- within standalone build of git-annex
that many git commands could crash randomly at various points with

fatal: Out of memory, getdelim failed

message.  Recently upstream tracked it down, and offered a perspective patch
(see attached, cherry-picked from git upstream repository) -- it is a very
simple patch.  I have tested it on our deployments (as applied against
1:2.11.0-3 in stretch, but it is applicable to sid/experimental version as
well)

original report upstream and the thread with further discussion(s) on
possible improvements to the patch:
https://public-inbox.org/git/20170809173928.h2ylvg5tp2p5i...@hopa.kiewit.dartmouth.edu/

Please please consider adapting this patch for the official packages of git in
Debian sid, and ideally to the version in stretch.  This would be of great help
to avoid those problems on the NFS-mounts and to generate fixed standalone
builds of git-annex (CCing git-annex author, Joey) which many users rely upon
on various (even non-Debian) systems.

Thank you very much in advance

-- System Information:
Debian Release: 9.0
  APT prefers unstable
  APT policy: (600, 'unstable'), (300, 'experimental'), (100, 
'unstable-debug'), (100, 'stable')
Architecture: amd64
 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.9.0-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages git depends on:
ii  dpkg             1.18.24
ii  git-man          1:2.14.0-1
ii  libc6            2.24-10
ii  libcurl3-gnutls  7.51.0-1
ii  liberror-perl    0.17024-1
ii  libexpat1        2.2.0-2
ii  libpcre2-8-0     10.22-3
ii  perl             5.26.0-5
ii  zlib1g           1:1.2.8.dfsg-5

Versions of packages git recommends:
ii  less                         481-2.1
ii  openssh-client [ssh-client]  1:7.4p1-10
ii  patch                        2.7.5-1+b2

Versions of packages git suggests:
ii  gettext-base                          0.19.8.1-2
pn  git-cvs                               <none>
pn  git-daemon-run | git-daemon-sysvinit  <none>
pn  git-doc                               <none>
ii  git-el                                1:2.11.0-3
ii  git-email                             1:2.14.0-1
ii  git-gui                               1:2.14.0-1
pn  git-mediawiki                         <none>
ii  git-svn                               1:2.14.0-1
ii  gitk                                  1:2.14.0-1
pn  gitweb                                <none>

-- no debconf information
>From 642956cf455ff8635be32b3160b12369da73cfe2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= <l....@web.de>
Date: Thu, 10 Aug 2017 22:56:40 +0200
Subject: [PATCH] strbuf: clear errno before calling getdelim(3)

getdelim(3) returns -1 at the end of the file and if it encounters an
error, but sets errno only in the latter case.  Set errno to zero before
calling it to avoid misdiagnosing an out-of-memory condition due to a
left-over value from some other function call.

Reported-by: Yaroslav Halchenko <y...@onerussian.com>
Suggested-by: Junio C Hamano <gits...@pobox.com>
Signed-off-by: Rene Scharfe <l....@web.de>
Signed-off-by: Junio C Hamano <gits...@pobox.com>
---
 strbuf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/strbuf.c b/strbuf.c
index ace58e7367..977acba31b 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -472,6 +472,7 @@ int strbuf_getwholeline(struct strbuf *sb, FILE *fp, int 
term)
        /* Translate slopbuf to NULL, as we cannot call realloc on it */
        if (!sb->alloc)
                sb->buf = NULL;
+       errno = 0;
        r = getdelim(&sb->buf, &sb->alloc, term, fp);
 
        if (r > 0) {
-- 
2.14.0

Reply via email to