coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tests/ls/stat-free-colors.sh broken with glibc-2.22


From: Pádraig Brady
Subject: Re: tests/ls/stat-free-colors.sh broken with glibc-2.22
Date: Sat, 29 Aug 2015 02:14:21 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 29/08/15 01:17, Bernhard Voelker wrote:
> The above test is broken with latest glibc, seen first on openSUSE:Factory:
> 
>   + strace -o log -e stat,lstat,stat64,lstat64,newfstatat ls --color=always .
>   color-without-stat
>   dangle
>   log
>   log-help
>   ++ wc -l
>   + n_lines=3
>   ++ expr 3 - 1
>   + n_stat=2
>   + case $n_stat in
>   + fail=1
>   + head -n30 log log-help
>   ==> log <==
>   stat(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
>   stat(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
>   +++ exited with 0 +++
> 
>   ==> log-help <==
>   +++ exited with 0 +++
>   + Exit 1
> 
> The effect is that for every directory-type argument, ls(1) does an extra
> call to stat().  I could trace it down to main()->print_dirs() which in
> turn calls glibc's opendir().
> 
> This is since glibc-2.22 ... and specifically this commit:
> https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=glibc-2.21-360-g46f894d

Good tracking down. Unfortunately there is no mention
in the commit as to _why_ the change was made.

> 
> As can be seen in the following diff of strace outputs, opendir(".") has
> been changed from a simple openat() to the sequence of stat()+open():
> 
>   ...
>    stat(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
>   -openat(AT_FDCWD, ".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
>   +stat(".", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
>   +open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
>   +fstat(3, {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0

Roland 2 extra stats per opendir seems excessive.
Is that required/avoidable?

> As we can't predict the number of stat() calls as before,
> what shall we do to fix the test?

Maybe something like:

  -strace -o log-help -e $stats ls --help >/dev/null || fail=1
  -n_lines_help=$(wc -l < log-help)
  +strace -o log-init -e $stats ls . >/dev/null || fail=1
  +n_lines_init=$(wc -l < log-init)

thanks,
Pádraig.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]