Subject: Re: rm 8.1

From: Brad <[email-masked]>
Date: Wed, 23 Jun 2010 14:34:15 -0700

Thanks Jim!

I knew you would know what to do. Please tell me what this all means. 
Here is the output 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 rm
Reading symbols from /home/brad/tools/core_debug/src/rm...done.
(gdb) b fts_open
Breakpoint 1 at 0x4015c8
(gdb) run -rf a/b/c/d
Starting program: /home/brad/tools/core_debug/src/rm -rf a/b/c/d

Breakpoint 1, fts_open (argv=0x7fffffffed08, options=536, compar=0) at 
fts.c:92
92      {
(gdb) n
100             if (options & ~FTS_OPTIONMASK) {
(gdb) n
101                     __set_errno (EINVAL);
(gdb) n
201     }
(gdb) n
xfts_open (argv=0x7fffffffed08, options=536, compar=0) at 
../../coreutils-8.5/lib/xfts.c:37
37        if (fts == NULL)
(gdb) n
41            assert (errno != EINVAL);
(gdb) n
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) n

Program terminated with signal SIGABRT, Aborted.
The program no longer exists.

Jim Meyering wrote:
> Brad wrote:
>> 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.
> ...
>> Please let me know if you have any
>> suggestions to get more information.
> 
> Thanks for the details.
> Here's how to get more:
> 
> First, recompile at least lib/fts.c using with -g added to CFLAGS,
> and relink say rm.
> 
> Create a tiny tree in src/ that we'll remove:
> 
>   cd src # if you weren't there already
>   mkdir -p a/b/c/d
> 
> Then run gdb on rm:
> 
>   gdb rm
> 
> set a breakpoint in fts_open (not xfts_open):
> 
>   b fts_open
> 
> run rm on that tree:
> 
>   run -rf a/b/c/d
> 
> Now, you'll see that gdb has stopped in fts_open.
> gdb's output will show the values of the function parameters,
> including the "options" variable.
> That's probably all I need, but just to be sure, continue
> a little further, and single step through it using "n" (for "next")
> until it returns:
> 
> One of the following three return statements should trigger:
> 
>         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);
>         }
> 
> Then show us the output of the above commands.
> 
> Thanks.
> 

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

619.808.2359