NetBSD Problem Report #44973

From www@NetBSD.org  Mon May 16 22:20:52 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 4E49163C474
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 16 May 2011 22:20:52 +0000 (UTC)
Message-Id: <20110516222051.A541863B8AC@www.NetBSD.org>
Date: Mon, 16 May 2011 22:20:51 +0000 (UTC)
From: nathanialsloss@yahoo.com.au
Reply-To: nathanialsloss@yahoo.com.au
To: gnats-bugs@NetBSD.org
Subject: Find -exit results in error.
X-Send-Pr-Version: www-1.0

>Number:         44973
>Category:       bin
>Synopsis:       Find -exit results in error.
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 16 22:25:00 +0000 2011
>Closed-Date:    Sun Mar 18 20:35:46 +0000 2012
>Last-Modified:  Sun Mar 18 20:35:46 +0000 2012
>Originator:     Nat Sloss
>Release:        NetBSD Current
>Organization:
>Environment:
NetBSD  5.99.51 NetBSD 5.99.51 (GENERIC) #0: Wed May 11 20:47:27 EST 2011  build@beast:/home/build/NetBSD-Current_source_tree/src/sys/arch/i386/compile/obj/GENERIC i386
>Description:
When using the find utility with the exit switch, it results in an error. 

ie: find /etc -type f -exit

You then receive an error: 
find: fts_read: No such file or directory

It should print nothing unless -print or similar is specified.

The same problem occurs on NetBSD 5.0.1 and 5.1.

Best regards,

Nat.
>How-To-Repeat:
At the shell type:

find /etc -type f -exit

It should just return to the prompt, instead you will receive an error.
>Fix:

>Release-Note:

>Audit-Trail:
From: Nat Sloss <nathanialsloss@yahoo.com.au>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/44973
Date: Sun, 27 Nov 2011 02:19:45 +1100

 Hi,

 I have a solution to the problem.

 Is seems errno is set to zero by fts_read when it returns null ie after all 
 entries have been read.  So I believe that errno should be set to zero upon 
 exiting as all entries have been read or rather discarded.

 So here is my patch:

 --- find.c.orig 2011-11-27 01:54:23.000000000 +1100
 +++ find.c      2011-07-02 11:07:27.000000000 +1000
 @@ -229,6 +229,7 @@
                         if (p->type == N_EXIT) {
                                 rval = p->exit_val;
                                 cval = 0;
 +                               errno = 0;
                         }
         }

 It works for me hopefully it will help others.

 Regards,

 Nat.

From: "Jukka Ruohonen" <jruoho@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44973 CVS commit: src
Date: Sun, 18 Mar 2012 12:40:43 +0000

 Module Name:	src
 Committed By:	jruoho
 Date:		Sun Mar 18 12:40:43 UTC 2012

 Modified Files:
 	src/distrib/sets/lists/tests: mi
 	src/etc/mtree: NetBSD.dist.tests
 	src/tests/usr.bin: Makefile
 Added Files:
 	src/tests/usr.bin/find: Makefile t_find.sh

 Log Message:
 Add a case for PR bin/44973.


 To generate a diff of this commit:
 cvs rdiff -u -r1.448 -r1.449 src/distrib/sets/lists/tests/mi
 cvs rdiff -u -r1.65 -r1.66 src/etc/mtree/NetBSD.dist.tests
 cvs rdiff -u -r1.10 -r1.11 src/tests/usr.bin/Makefile
 cvs rdiff -u -r0 -r1.1 src/tests/usr.bin/find/Makefile \
     src/tests/usr.bin/find/t_find.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44973 CVS commit: src/usr.bin/find
Date: Sun, 18 Mar 2012 17:09:46 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Sun Mar 18 17:09:46 UTC 2012

 Modified Files:
 	src/usr.bin/find: find.c

 Log Message:
 Avoid testing a possibly uninitialized errno value when using -exit.
 Closes PR 44973 (change is a somewhat more principled equivalent of
 the patch suggested there) although I cannot replicate the reported
 behavior unless I explicitly prepare errno with a nonzero value before
 the fts_read loop.


 To generate a diff of this commit:
 cvs rdiff -u -r1.27 -r1.28 src/usr.bin/find/find.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: David Holland <dholland-bugs@netbsd.org>
To: Jukka Ruohonen <jruoho@netbsd.org>, gnats-bugs@netbsd.org
Cc: 
Subject: Re: PR/44973 CVS commit: src
Date: Sun, 18 Mar 2012 17:19:49 +0000

 On Sun, Mar 18, 2012 at 12:45:02PM +0000, Jukka Ruohonen wrote:
  > From: "Jukka Ruohonen" <jruoho@netbsd.org>
  > [...]
  >  
  >  Log Message:
  >  Add a case for PR bin/44973.

 I deduce from this that you can replicate the visible behavior, so
 could you try my fix?

 (since the visible behavior depends on what gets left in errno, it
 probably varies with exact libc version)

 -- 
 David A. Holland
 dholland@netbsd.org

State-Changed-From-To: open->feedback
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 18 Mar 2012 17:20:33 +0000
State-Changed-Why:
A candidate fix was committed, please try it.


From: Jukka Ruohonen <jruohonen@iki.fi>
To: gnats-bugs@NetBSD.org
Cc: gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
	nathanialsloss@yahoo.com.au
Subject: Re: PR/44973 CVS commit: src
Date: Sun, 18 Mar 2012 19:25:15 +0200

 On Sun, Mar 18, 2012 at 05:20:04PM +0000, David Holland wrote:
 >  I deduce from this that you can replicate the visible behavior, so
 >  could you try my fix?

 No I can't. The test I added was bogus and/or due ATF (see the message
 on source-changes-d@). Unfortunately I realized that after my commit.

 - Jukka.

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org, jruohonen@iki.fi
Cc: 
Subject: Re: PR/44973 CVS commit: src
Date: Sun, 18 Mar 2012 17:32:19 +0000

 On Sun, Mar 18, 2012 at 07:25:15PM +0200, Jukka Ruohonen wrote:
  > On Sun, Mar 18, 2012 at 05:20:04PM +0000, David Holland wrote:
  > >  I deduce from this that you can replicate the visible behavior, so
  > >  could you try my fix?
  > 
  > No I can't. The test I added was bogus and/or due ATF (see the message
  > on source-changes-d@). Unfortunately I realized that after my commit.

 Oh right, I saw that when I was reading source-changes, but didn't put
 it together.

 Anyway, I think I've fixed the problem, so unless you object I'll take
 out the xfail declaration in the test.

 -- 
 David A. Holland
 dholland@netbsd.org

From: Jukka Ruohonen <jruohonen@iki.fi>
To: David Holland <dholland-bugs@netbsd.org>
Cc: gnats-bugs@netbsd.org, jruohonen@iki.fi
Subject: Re: PR/44973 CVS commit: src
Date: Sun, 18 Mar 2012 19:35:34 +0200

 On Sun, Mar 18, 2012 at 05:32:19PM +0000, David Holland wrote:
 > Anyway, I think I've fixed the problem, so unless you object I'll take
 > out the xfail declaration in the test.

 Please do.

 I'd like to understand the issue though too...

 - Jukka.

From: Nicolas Joly <njoly@pasteur.fr>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: PR/44973 CVS commit: src
Date: Sun, 18 Mar 2012 18:39:36 +0100

 On Sun, Mar 18, 2012 at 05:20:04PM +0000, David Holland wrote:
 > The following reply was made to PR bin/44973; it has been noted by GNATS.
 > 
 > From: David Holland <dholland-bugs@netbsd.org>
 > To: Jukka Ruohonen <jruoho@netbsd.org>, gnats-bugs@netbsd.org
 > Cc: 
 > Subject: Re: PR/44973 CVS commit: src
 > Date: Sun, 18 Mar 2012 17:19:49 +0000
 > 
 >  On Sun, Mar 18, 2012 at 12:45:02PM +0000, Jukka Ruohonen wrote:
 >   > From: "Jukka Ruohonen" <jruoho@netbsd.org>
 >   > [...]
 >   >  
 >   >  Log Message:
 >   >  Add a case for PR bin/44973.
 >  
 >  I deduce from this that you can replicate the visible behavior, so
 >  could you try my fix?
 >  
 >  (since the visible behavior depends on what gets left in errno, it
 >  probably varies with exact libc version)

 I do see an error with stdin closed ...

 njoly@lanfeust [~]> find /etc -type f -exit
 njoly@lanfeust [~]> find /etc -type f -exit </dev/null
 find: fts_read: Inappropriate ioctl for device

 -- 
 Nicolas Joly

 Projects and Developments in Bioinformatics
 Institut Pasteur, Paris.

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: PR/44973 CVS commit: src
Date: Sun, 18 Mar 2012 18:01:05 +0000

 On Sun, Mar 18, 2012 at 05:40:17PM +0000, Nicolas Joly wrote:
  >  >   >  Log Message:
  >  >   >  Add a case for PR bin/44973.
  >  >  
  >  >  I deduce from this that you can replicate the visible behavior, so
  >  >  could you try my fix?
  >  >  
  >  >  (since the visible behavior depends on what gets left in errno, it
  >  >  probably varies with exact libc version)
  >  
  >  I do see an error with stdin closed ...
  >  
  >  njoly@lanfeust [~]> find /etc -type f -exit
  >  njoly@lanfeust [~]> find /etc -type f -exit </dev/null
  >  find: fts_read: Inappropriate ioctl for device

 That goes away with my fix, so I guess the fix works...

 -- 
 David A. Holland
 dholland@netbsd.org

From: "David A. Holland" <dholland@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/44973 CVS commit: src/tests/usr.bin/find
Date: Sun, 18 Mar 2012 18:09:46 +0000

 Module Name:	src
 Committed By:	dholland
 Date:		Sun Mar 18 18:09:45 UTC 2012

 Modified Files:
 	src/tests/usr.bin/find: t_find.sh

 Log Message:
 Remove xfail as PR 44973 is fixed. (Note that it was Nat Sloss who did
 the work of figuring out what was wrong.)


 To generate a diff of this commit:
 cvs rdiff -u -r1.1 -r1.2 src/tests/usr.bin/find/t_find.sh

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: feedback->closed
State-Changed-By: dholland@NetBSD.org
State-Changed-When: Sun, 18 Mar 2012 20:35:46 +0000
State-Changed-Why:
The problem is fixed, thanks for tracking it down.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.