Subject: Re: rm 8.1
From: Jim Meyering <[email-masked]>
To: Brad <[email-masked]>
Cc: [email-masked]
Date: Wed, 23 Jun 2010 21:58:14 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

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?