All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Horst Schirmeier <horst@schirmeier.com>
Cc: git@vger.kernel.org
Subject: [PATCH 1/6] receive-pack: fix deadlock when we cannot create tmpdir
Date: Tue, 7 Mar 2017 08:35:34 -0500	[thread overview]
Message-ID: <20170307133534.bgar57ojq52snns3@sigill.intra.peff.net> (raw)
In-Reply-To: <20170307133437.qee2jtynbiwf6uzr@sigill.intra.peff.net>

The err_fd descriptor passed to the unpack() function is
intended to be handed off to the child index-pack, and our
async muxer will read until it gets EOF. However, if we
encounter an error before handing off the descriptor, we
must manually close(err_fd). Otherwise we will be waiting
for our muxer to finish, while the muxer is waiting for EOF
on err_fd.

We fixed an identical deadlock already in 49ecfa13f
(receive-pack: close sideband fd on early pack errors,
2013-04-19). But since then, the function grew a new
early-return in 722ff7f87 (receive-pack: quarantine objects
until pre-receive accepts, 2016-10-03), when we fail to
create a temporary directory. This return needs the same
treatment.

Reported-by: Horst Schirmeier <horst@schirmeier.com>
Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/receive-pack.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 9ed8fbbfa..f2c6953a3 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1667,8 +1667,11 @@ static const char *unpack(int err_fd, struct shallow_info *si)
 	}
 
 	tmp_objdir = tmp_objdir_create();
-	if (!tmp_objdir)
+	if (!tmp_objdir) {
+		if (err_fd > 0)
+			close(err_fd);
 		return "unable to create temporary object directory";
+	}
 	child.env = tmp_objdir_env(tmp_objdir);
 
 	/*
-- 
2.12.0.429.gde83c8049


  reply	other threads:[~2017-03-07 13:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-07 11:03 regression: git push in non-shared repo stalls (v2.11.0+) Horst Schirmeier
2017-03-07 11:14 ` Horst Schirmeier
2017-03-07 13:34   ` [PATCH 0/6] deadlock regression in v2.11.0 with failed mkdtemp Jeff King
2017-03-07 13:35     ` Jeff King [this message]
2017-03-07 13:35     ` [PATCH 2/6] send-pack: extract parsing of "unpack" response Jeff King
2017-03-07 13:36     ` [PATCH 3/6] send-pack: use skip_prefix for parsing unpack status Jeff King
2017-03-07 13:37     ` [PATCH 4/6] send-pack: improve unpack-status error messages Jeff King
2017-03-07 22:56       ` Junio C Hamano
2017-03-08  5:45         ` Jeff King
2017-03-08 17:19           ` Junio C Hamano
2017-03-07 13:38     ` [PATCH 5/6] send-pack: read "unpack" status even on pack-objects failure Jeff King
2017-03-07 13:39     ` [PATCH 6/6] send-pack: report signal death of pack-objects Jeff King
2017-03-07 13:50     ` [PATCH 0/6] deadlock regression in v2.11.0 with failed mkdtemp Jeff King
2017-03-08 17:58     ` Horst Schirmeier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170307133534.bgar57ojq52snns3@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=horst@schirmeier.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.