GNU bug report logs - #10305
coreutils-8.14, "rm -r" fails with EBADF

Previous Next

Package: coreutils;

Reported by: "Joachim Schmitz" <jojo <at> schmitz-digital.de>

Date: Thu, 15 Dec 2011 14:08:01 UTC

Severity: wishlist

Tags: notabug

Full log


View this message in rfc822 format

From: Jim Meyering <jim <at> meyering.net>
To: "Joachim Schmitz" <jojo <at> schmitz-digital.de>
Cc: 10305 <at> debbugs.gnu.org, eggert <at> cs.ucla.edu, bug-gnulib <at> gnu.org
Subject: bug#10305: coreutils-8.14, "rm -r" fails with EBADF
Date: Fri, 16 Dec 2011 11:51:00 +0100
Joachim Schmitz wrote:

>> From: Paul Eggert [mailto:eggert <at> cs.ucla.edu]
>> Sent: Thursday, December 15, 2011 7:07 PM
>> To: Joachim Schmitz
>> Cc: Jim Meyering; bug-coreutils <at> gnu.org; bug-gnulib <at> gnu.org
>> Subject: Re: coreutils-8.14, "rm -r" fails with EBADF
>>
>> On 12/15/11 08:28, Jim Meyering wrote:
>> > If you can debug it further to narrow down what/how it is failing,
>> > eventually we'll find the cause.
>>
>> One way to do that might be to put a breakpoint on all the following
> functions,
>> and to let us know what their arguments are when called, and what they
>> return.  You also might try to compile coreutils with debugging turned
> off, so
>> that functions aren't inlined.
>
> I guess you meant turn of optimization rather than debugging?
>
>> diropen
>> fts_build
>> fts_safe_changedir
>> restore_initial_cwd
>> fchdir
>> cwd_advance_fd
>
> OK here we go:
> jojo@\hpitug:/home/jojo/Floss/coreutils-8.14/src $ run -debug -inspect=on
> ./rm -r /tmp/foo
...
> Stepping into fts_build shows that the dup(dir_fd) in line 1385 fails, with
> errno being set to EBADF
>
> * 1375              if (continue_readdir)
> (eInspect 1,840):
> * 1381              else if (nlinks || type == BREAD) {
> (eInspect 1,840):
> * 1382                      if (ISSET(FTS_CWDFD))
> (eInspect 1,840):
> * 1384                          dir_fd = dup (dir_fd);
> (eInspect 1,840):p dir_fd
> $3 = 3
> (eInspect 1,840):next
> * 1385                          if (0 <= dir_fd)
> (eInspect 1,840):p dir_fd
> $4 = -1
...
> So... it seems we can't dup() an fd for a directory here!

Right.
Your config.h file suggests you're not using a gnulib dup replacement,
so I suspect a bug in your system's dup implementation.

I thought gnulib had pretty good dup* test coverage,
but see that no dup* test uses a directory file descriptor.




This bug report was last modified 12 years and 110 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.