GNU bug report logs -
#25283
grep: (standard input): invalid argument when run from make
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 25283 in the body.
You can then email your comments to 25283 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-grep <at> gnu.org
:
bug#25283
; Package
grep
.
(Tue, 27 Dec 2016 18:29:01 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Benno Fünfstück <benno.fuenfstueck <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-grep <at> gnu.org
.
(Tue, 27 Dec 2016 18:29:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The following Makefile illustrates the issue:
$ cat >Makefile <<EOF
all:
echo "abc" | grep "b"
.PHONY: all
$ make all # works as expected
$ make all > /dev/null
grep: (standard input): Invalid argument
make: *** [Makefile:2: all] Error 2
The bug was introduced by commit 4fa6f48b573267e758650e114ec158d97916411e
(introducing the usage of splice), which was first released in grep version
2.27.
My environment:
$ make --version
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ grep --version
grep (GNU grep) 2.27
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <
http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
Patch attached.
--
Benno Fünfstück
[Message part 2 (text/html, inline)]
[fix-splice-einval.patch (text/x-patch, attachment)]
Reply sent
to
Paul Eggert <eggert <at> cs.ucla.edu>
:
You have taken responsibility.
(Tue, 27 Dec 2016 19:24:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Benno Fünfstück <benno.fuenfstueck <at> gmail.com>
:
bug acknowledged by developer.
(Tue, 27 Dec 2016 19:24:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 25283-done <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Thanks for reporting that problem. I wonder why GNU 'make' sets stdout to append
mode? That surprises me, and I don't see where POSIX allows it. Anyway, it's
clearly a bug in 'grep' no matter what 'make' is doing. I wrote up a test case
for the bug and installed the attached, which is a bit more conservative than
the patch you submitted.
[0001-grep-fix-bug-with-.-grep-pat-dev-null.txt (text/plain, attachment)]
Information forwarded
to
bug-grep <at> gnu.org
:
bug#25283
; Package
grep
.
(Tue, 27 Dec 2016 21:51:01 GMT)
Full text and
rfc822 format available.
Message #13 received at 25283 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On 27 Dec 2016 11:23, Paul Eggert wrote:
> Thanks for reporting that problem. I wonder why GNU 'make' sets stdout to append
> mode? That surprises me, and I don't see where POSIX allows it. Anyway, it's
> clearly a bug in 'grep' no matter what 'make' is doing. I wrote up a test case
> for the bug and installed the attached, which is a bit more conservative than
> the patch you submitted.
fwiw, this patch also fixes misbehavior when stdout & stderr are the same fd.
i mention it only because the NEWS entry was documenting different cases the
failure could come up.
this fails:
(make -v | grep .) >/dev/null 2>&1
but this works:
(make -v | grep .) >/dev/null 2>/dev/null
stracing shows same issue:
splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = -1 EINVAL (Invalid argument)
write(2, "/bin/grep: ", 11) = 11
write(2, "(standard input)", 16) = 16
write(2, ": Invalid argument", 18) = 18
write(2, "\n", 1) = 1
close(1) = 0
close(2) = 0
exit_group(2) = ?
-mike
[signature.asc (application/pgp-signature, inline)]
Information forwarded
to
bug-grep <at> gnu.org
:
bug#25283
; Package
grep
.
(Tue, 27 Dec 2016 22:15:01 GMT)
Full text and
rfc822 format available.
Message #16 received at 25283 <at> debbugs.gnu.org (full text, mbox):
Mike Frysinger wrote:
> this fails:
> (make -v | grep .) >/dev/null 2>&1
>
> but this works:
> (make -v | grep .) >/dev/null 2>/dev/null
That's the same issue, because GNU 'make' sets stderr's O_APPEND flag too, so in
the former case grep's stdout is in append mode whereas in the latter case it's not.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Wed, 25 Jan 2017 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 7 years and 93 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.