From: Jeff King <peff@peff.net>
To: Johannes Sixt <j6t@kdbg.org>
Cc: Junio C Hamano <gitster@pobox.com>, git@vger.kernel.org
Subject: Re: [PATCH 3/3] diff: add "fasttextconv" config option
Date: Tue, 30 Mar 2010 12:30:04 -0400 [thread overview]
Message-ID: <20100330163004.GC17763@coredump.intra.peff.net> (raw)
In-Reply-To: <201003282023.00913.j6t@kdbg.org>
On Sun, Mar 28, 2010 at 08:23:00PM +0200, Johannes Sixt wrote:
> On Sonntag, 28. März 2010, Jeff King wrote:
> > + if (start_command(&child) != 0 ||
> > + strbuf_read(&buf, child.out, 0) < 0 ||
> > + finish_command(&child) != 0) {
>
> This conditional is somewhat dubious. If strbuf_read fails, you do not wait
> for the child, and a zombie remains.
>
> The have this sequence already in run_textconv().
Ugh. I would blame the author of run_textconv, but that is also me. :)
I doubt it is a big deal in practice, as the read() call is the least
likely to produce an error, and even if we do get a zombie, it will die
along with the diffing process. But it is still worth fixing. Thanks for
noticing.
Junio, can you apply the patch below to maint?
-- >8 --
Subject: [PATCH] diff: fix textconv error zombies
To make the code simpler, run_textconv lumps all of its
error checking into one conditional. However, the
short-circuit means that an error in reading will prevent us
from calling finish_command, leaving a zombie child.
The cleanup requirements are actually different for each of
the three error checks, so let's just write them out
longhand.
Signed-off-by: Jeff King <peff@peff.net>
---
Yes, there are clever ways to make this shorter, but I think it is
clearer just written out.
diff.c | 16 +++++++++++++---
1 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/diff.c b/diff.c
index 0d465fa..c268cfc 100644
--- a/diff.c
+++ b/diff.c
@@ -3875,9 +3875,19 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,
child.use_shell = 1;
child.argv = argv;
child.out = -1;
- if (start_command(&child) != 0 ||
- strbuf_read(&buf, child.out, 0) < 0 ||
- finish_command(&child) != 0) {
+ if (start_command(&child) != 0) {
+ remove_tempfile();
+ error("error running textconv command '%s'", pgm);
+ return NULL;
+ }
+ if (strbuf_read(&buf, child.out, 0) < 0) {
+ close(child.out);
+ finish_command(&child);
+ remove_tempfile();
+ error("error reading from textconv command '%s'", pgm);
+ return NULL;
+ }
+ if (finish_command(&child) != 0) {
close(child.out);
strbuf_release(&buf);
remove_tempfile();
--
1.7.0.3.460.g6f052
next prev parent reply other threads:[~2010-03-30 16:30 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-28 14:53 [PATCH 0/3] fast textconv Jeff King
2010-03-28 14:53 ` [PATCH 1/3] textconv: refactor calls to run_textconv Jeff King
2010-03-28 14:53 ` [PATCH 2/3] textconv: refactor to handle multiple textconv types Jeff King
2010-03-28 14:54 ` [PATCH 3/3] diff: add "fasttextconv" config option Jeff King
2010-03-28 18:23 ` Johannes Sixt
2010-03-30 16:30 ` Jeff King [this message]
2010-03-30 17:36 ` [PATCH] diff: fix textconv error zombies Johannes Sixt
2010-03-30 21:46 ` Junio C Hamano
2010-03-30 22:17 ` Johannes Sixt
2010-03-30 22:56 ` Jeff King
2010-03-28 16:09 ` [PATCH 0/3] fast textconv Michael J Gruber
2010-03-28 16:17 ` Jeff King
2010-03-28 16:19 ` Jeff King
2010-03-28 16:56 ` Jeff King
2010-03-28 17:34 ` Jeff King
2010-03-28 18:13 ` Sverre Rabbelier
2010-03-30 16:04 ` Jeff King
2010-03-30 3:52 ` Junio C Hamano
2010-03-30 17:07 ` Jeff King
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=20100330163004.GC17763@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).