GNU bug report logs - #29826
nondeterministic Broken pipe

Previous Next

Package: guix;

Reported by: Alex Vong <alexvong1995 <at> gmail.com>

Date: Sat, 23 Dec 2017 20:25:01 UTC

Severity: normal

Merged with 34209

Full log


View this message in rfc822 format

From: ludo <at> gnu.org (Ludovic Courtès)
To: Alex Vong <alexvong1995 <at> gmail.com>
Cc: Mark H Weaver <mhw <at> netris.org>, 29826 <at> debbugs.gnu.org
Subject: bug#29826: nondeterministic Broken pipe
Date: Sun, 31 Dec 2017 11:11:15 +0100
Hi,

Alex Vong <alexvong1995 <at> gmail.com> skribis:

> Mark H Weaver <mhw <at> netris.org> writes:
>
>> Alex Vong <alexvong1995 <at> gmail.com> writes:
>>
>>> I get the following error when running ``guix --version | head -n 1''. I
>>> can get similar after replacing ``--version'' with ``--help''. Also, the
>>> error is nondeterministic. Any idea?
>>
>> Attempts to write to a pipe that has already been closed on the other
>> end results in EPIPE.  From the write(2) man page:
>>
>>   EPIPE fd is connected to a pipe or socket whose reading end is closed.
>>         When this happens the writing process will also receive a
>>         SIGPIPE signal.  (Thus, the write return value is seen only if
>>         the program catches, blocks or ignores this signal.)
>>
>> In this case, there's a race condition.  The result depends on whether
>> "head -n 1" closes its end of the pipe before or after "guix --version"
>> is finished writing all of its output.  If "head -n 1" closes the pipe
>> first, then "guix --version" will receive EPIPE while attempting to
>> write to it.
>>
>> What normally happens is that the sending process receives SIGPIPE,
>> which simply causes it to exit prematurely without ever receiving this
>> error.  However, since Guix arranges to ignore SIGPIPE in
>> 'initialize-guix' in guix/ui.scm, we receive EPIPE.
>>
>> That's what's happening here.  I'll need to think on how best to fix it.
>>
>>      Regards,
>>        Mark
>
> Nice explaination as always! I forget to mention that I reported a bug
> of similar flavour before <http://bugs.gnu.org/27017>. I agree that
> thought is needed to fix all instances of this type of bug.

Not sure!  We specifically ignore EPIPE in cases where it matters, such
as for the output of ‘guix package --search’, ‘guix package -A’, etc.
In other cases, it’s probably an error, so it’s worth reporting.

WDYT?

In C such errors are usually ignored, which is nice for shell hackery
but otherwise not so great.

Ludo’.




This bug report was last modified 6 years and 133 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.