Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.debian.devel.testing > #1030 > unrolled thread

grep-2.27-1 fails when >/dev/null 2>&1

Started byLars Bro <larsbro@gmail.com>
First post2017-01-03 21:50 +0100
Last post2017-01-15 23:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.debian.devel.testing


Contents

  grep-2.27-1 fails when >/dev/null 2>&1 Lars Bro <larsbro@gmail.com> - 2017-01-03 21:50 +0100
    Re: grep-2.27-1 fails when >/dev/null 2>&1 Adrian Bunk <bunk@debian.org> - 2017-01-15 23:10 +0100

#1030 — grep-2.27-1 fails when >/dev/null 2>&1

FromLars Bro <larsbro@gmail.com>
Date2017-01-03 21:50 +0100
Subjectgrep-2.27-1 fails when >/dev/null 2>&1
Message-ID<sVEbU-3aT-5@gated-at.bofh.it>

[Multipart message — attachments visible in raw view] — view raw

Hi list,

I am using Debian Stretch, obtained with debootstrap (as of Jan 02 2017).
Linux kernel of the host is 4.4.6, and the following is run in a chroot.
File system is ext4.

When I try to run "./configure" of one of the applications I use, it fails,
claiming that gmake is not present.

When looking into the "configure script" I find this construct:

/bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1

And when I test it, I see this:

root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1
root@mini:/# echo $?
2
root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>/dev/null
root@mini:/# echo $?

0
root@mini:/#

There is apparently something that goes wrong when "dup(2)" is used as in
2>&1

I did an strace of the two constructs:
This is the failing:

"/bin/sh -c 'make --version | gre"..., 8192) = 55
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
fcntl(2, F_DUPFD, 10)                   = 12
close(2)                                = 0
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
dup2(1, 2)

[pid 11678] read(0, "GNU Make 4.1\nBuilt for x86_64-pc"..., 32768) =
297
[pid 11678] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = -1
EINVAL
(Invalid argument)


And this one works

read(0,  /bin/sh -c 'make --version | grep GNU' > /dev/null
2>/dev/null
" /bin/sh -c 'make --version | gr"..., 8192) = 64
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(1, F_DUPFD, 10)                   = 11
close(1)                                = 0
fcntl(11, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 1)                              = 1
close(3)                                = 0
open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
fcntl(2, F_DUPFD, 10)                   = 12
close(2)                                = 0
fcntl(12, F_SETFD, FD_CLOEXEC)          = 0
dup2(3, 2)                              = 2
close(3)

[pid 11689] read(0, "GNU Make 4.1\nBuilt for x86_64-pc"..., 32768) =
297
[pid 11689] splice(0, NULL, 1, NULL, 32768, SPLICE_F_MOVE) = 0

This suggests that there is something with the "splice(2)" system call.

I tried with grep_2.25-6 wich was in Stretch before. It works as below:

[pid 11821] <... read resumed> "GNU Make 4.1\nBuilt for x86_64-
pc"...,
32768) = 297
...
[pid 11821] read(0, "", 32768)          = 0
[pid 11821] write(1, "GNU Make 4.1\nLicense GPLv3+: GNU"..., 91) = 91


It seems to work because it uses read(0,...) and write(1,...) instead of
splice().

I could temporarily downgrade grep to that version, but I fear that the
problem may be of a more general nature.

yours,

Lars Bro

[toc] | [next] | [standalone]


#1033

FromAdrian Bunk <bunk@debian.org>
Date2017-01-15 23:10 +0100
Message-ID<t019U-84C-19@gated-at.bofh.it>
In reply to#1030
On Tue, Jan 03, 2017 at 09:39:59PM +0100, Lars Bro wrote:
> Hi list,

Hi Lars,

> I am using Debian Stretch, obtained with debootstrap (as of Jan 02 2017).
> Linux kernel of the host is 4.4.6, and the following is run in a chroot.
> File system is ext4.
> 
> When I try to run "./configure" of one of the applications I use, it fails,
> claiming that gmake is not present.
> 
> When looking into the "configure script" I find this construct:
> 
> /bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1
> 
> And when I test it, I see this:
> 
> root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>&1
> root@mini:/# echo $?
> 2
> root@mini:/# /bin/sh -c 'make --version | grep GNU' >/dev/null 2>/dev/null
> root@mini:/# echo $?
> 0
> root@mini:/#
>...

thanks for your report, can you submit it as a bug report against the 
grep package?

Upstream bug report and patch for this issue are at
  https://debbugs.gnu.org/cgi/bugreport.cgi?bug=25283

> yours,
> 
> Lars Bro

Thanks
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed

[toc] | [prev] | [standalone]


Back to top | Article view | linux.debian.devel.testing


csiph-web