Subject: bug#6500: rm 8.1

From: Brad <[email-masked]>
Date: Wed, 23 Jun 2010 13:52:51 -0700

Thanks for your help Jim. I tried to debug the program by running gdb. 
I'm not sure if the backtrace has the information you need.

GNU gdb (GDB) 7.1
Copyright (C) 2010 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.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-unknown-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) file src/rm
Reading symbols from /home/brad/tools/core_boot/src/rm...(no debugging 
symbols found)...done.
(gdb) set args test
(gdb) run
Starting program: /home/brad/tools/core_boot/src/rm test
rm: ../../coreutils-8.5/lib/xfts.c:41: xfts_open: Assertion 
`(*__errno_location ()) != 22' failed.

Program received signal SIGABRT, Aborted.
0x00007ffff7abb035 in *__GI_raise (sig=<value optimized out>) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:64
64        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);
(gdb) bt
#0  0x00007ffff7abb035 in *__GI_raise (sig=<value optimized out>) at 
../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1  0x00007ffff7abc460 in *__GI_abort () at abort.c:92
#2  0x00007ffff7ab4171 in *__GI___assert_fail (assertion=0x407def 
"(*__errno_location ()) != 22",
     file=<value optimized out>, line=41, function=0x407e0c "xfts_open") 
at assert.c:81
#3  0x0000000000406179 in xfts_open ()
#4  0x00000000004031dc in rm ()
#5  0x00000000004022d2 in main ()

I am not an expert at using gdb. Please let me know if you have any 
suggestions to get more information.

My environment is somewhat unusual. I am compiling a new system in 
/bootstrap against the updated glibc. The new system boots up with 
glibc-2.11.2. The development environment uses the older glibc-2.10.1. 
So I need to adjust the compiler spec file to ensure that the right 
linkage is done.

The sources were not modified. Everything compiles fine but the 
xfts_open is not working.

Here are the options to configure:

../coreutils-8.5/configure --prefix=/bootstrap --without-gmp 
CFLAGS='-specs=/bootstrap/gcc.specs' LDFLAGS=-Wl,-rpath,/bootstrap/lib,-lc

Here is how I adjusted the specs:

diff built-in.specs /bootstrap/gcc.specs
51c51
< %{!static:--eh-frame-hdr} %{!m32:-m elf_x86_64} %{m32:-m elf_i386} 
--hash-style=both   %{shared:-shared}   %{!shared:     %{!static: 
%{rdynamic:-export-dynamic} 
%{m32:%{!dynamic-linker:-dynamic-linker %{muclibc:%{mglibc:%e-mglibc and 
-muclibc used together}/lib/ld-uClibc.so.0;:/lib32/ld-linux.so.2}}} 
   %{!m32:%{!dynamic-linker:-dynamic-linker %{muclibc:%{mglibc:%e-mglibc 
and -muclibc used 
together}/lib/ld64-uClibc.so.0;:/lib/ld-linux-x86-64.so.2}}}} 
%{static:-static}}
---
 > %{!static:--eh-frame-hdr} %{!m32:-m elf_x86_64} %{m32:-m elf_i386} 
--hash-style=both   %{shared:-shared}   %{!shared:     %{!static: 
%{rdynamic:-export-dynamic} 
%{m32:%{!dynamic-linker:-dynamic-linker %{muclibc:%{mglibc:%e-mglibc and 
-muclibc used together}/lib/ld-uClibc.so.0;:/lib32/ld-linux.so.2}}} 
   %{!m32:%{!dynamic-linker:-dynamic-linker %{muclibc:%{mglibc:%e-mglibc 
and -muclibc used 
together}/lib/ld64-uClibc.so.0;:/bootstrap/lib/ld-linux-x86-64.so.2}}}} 
     %{static:-static}}
54c54
< %{pthread:-lpthread}    %{shared:-lc}    %{!shared:%{mieee-fp:-lieee} 
%{profile:-lc_p}%{!profile:-lc}}
---
 > %{pthread:-lpthread}    %{shared:-L/bootstrap/lib -lc} 
%{!shared:%{mieee-fp:-lieee} %{profile:-lc_p}%{!profile:-lc}}

Please let me know if you need more information. I can always modify the 
sources to gain useful debugging data. Hopefully you have a better idea.

Jim Meyering wrote:
> Brad wrote:
>> Hi Jim:
> 
> Hi Brad,
> 
> I've Cc'd the bug-reporting address.
> It's better to report problems to that address than to my personal one.
> 
>> Are you sure this is fixed?
> 
> How could I be sure it is fixed, considering
> that this is the first I've heard of this failure?
> 
>> I get these errors:
>> rm: ../../coreutils-8.5/lib/xfts.c:41: xfts_open: Assertion
>> (*__errno_location ()) != 22' failed.
>> Aborted
>>
>> chmod: ../../coreutils-8.5/lib/xfts.c:41: xfts_open: Assertion
>> (*__errno_location ()) != 22' failed.
>> Aborted
>>
>> du: ../../coreutils-8.5/lib/xfts.c:41: xfts_open: Assertion
>> (*__errno_location ()) != 22' failed.
>> Aborted
>>
>> It appears that the call to fts_open is failing but I do not
>> understand the reason. All of the other utilities that don't use this
>> function are still working fine.
>>
>> The system is running kernel 2.6.34 and the binaries are linked to
>> glibc-2.11.2. I had to use slackware binaries for rm and chmod in
>> order to get the system to boot. Clearly this is not right.
>>
>> If you have any ideas what might be wrong I would be glad to help fix
>> this. I look forward to your input.
> 
> You seem to be hitting this assertion:
> 
> FTS *
> xfts_open (char * const *argv, int options,
>            int (*compar) (const FTSENT **, const FTSENT **))
> {
>   FTS *fts = fts_open (argv, options | FTS_CWDFD, compar);
>   if (fts == NULL)
>     {
>       /* This can fail in two ways: out of memory or with errno==EINVAL,
>          which indicates it was called with invalid bit_flags.  */
>       assert (errno != EINVAL);
>       xalloc_die ();
>     }
> 
>   return fts;
> }
> 
> Did you build the failing rm yourself?
>>>From unmodified sources?
> If so, please provide the precise ./configure and "make"
> commands you used and tell us more about your system.
> 
> As far as I know, this is the first report of such a problem,
> so I suspect something about your environment is at least "unusual".
> 
> There are only a few ways fts_open can return with errno
> set to EINVAL, and none should be possible from coreutils programs:
> 
> FTS *
> fts_open (char * const *argv,
>           register int options,
>           int (*compar) (FTSENT const **, FTSENT const **))
> {
>         register FTS *sp;
>         register FTSENT *p, *root;
>         register size_t nitems;
>         FTSENT *parent = NULL;
>         FTSENT *tmp = NULL;     /* pacify gcc */
>         bool defer_stat;
> 
>         /* Options check. */
>         if (options & ~FTS_OPTIONMASK) {
>                 __set_errno (EINVAL);
>                 return (NULL);
>         }
>         if ((options & FTS_NOCHDIR) && (options & FTS_CWDFD)) {
>                 __set_errno (EINVAL);
>                 return (NULL);
>         }
>         if ( ! (options & (FTS_LOGICAL | FTS_PHYSICAL))) {
>                 __set_errno (EINVAL);
>                 return (NULL);
>         }
> 
> Can you debug it and tell us which one it is?
> 

-- 
Brad Mells
Quantum Harmonics
889 Mowry Ave #86
Fremont CA 94536

619.808.2359