From slaven.rezic@berlin.de  Sat Mar  9 03:33:07 2002
Return-Path: <slaven.rezic@berlin.de>
Received: from mailoutvl21.berlin.de (mail.berlin.de [195.243.105.33])
	by hub.freebsd.org (Postfix) with ESMTP id A40AA37B404
	for <FreeBSD-gnats-submit@freebsd.org>; Sat,  9 Mar 2002 03:33:05 -0800 (PST)
Received: from herceg.de ([213.7.184.60]) by mailoutvl21.berlin.de
          (InterMail vK.4.03.05.00 201-232-132 license c0e4b842f1eddc5308d584e55543c802)
          with ESMTP id <20020309113508.GRUF27460.mailoutvl21@herceg.de>
          for <FreeBSD-gnats-submit@freebsd.org>;
          Sat, 9 Mar 2002 12:35:08 +0100
Received: (from eserte@localhost)
	by vran.herceg.de (8.11.4/8.9.3) id g29BS7103320;
	Sat, 9 Mar 2002 12:28:07 +0100 (CET)
	(envelope-from eserte)
Message-Id: <200203091128.g29BS7103320@vran.herceg.de>
Date: Sat, 9 Mar 2002 12:28:07 +0100 (CET)
From: Slaven Rezic <eserte@vran.herceg.de>
Reply-To: Slaven Rezic <slaven.rezic@berlin.de>
To: FreeBSD-gnats-submit@freebsd.org
Subject: /proc/curproc/file returns unknown
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         35703
>Category:       kern
>Synopsis:       /proc/curproc/file returns unknown
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 09 03:40:04 PST 2002
>Closed-Date:    Fri Nov 16 02:46:15 UTC 2007
>Last-Modified:  Fri Nov 16 02:46:15 UTC 2007
>Originator:     Slaven Rezic
>Release:        FreeBSD 4.3-STABLE i386
>Organization:
www.rezic.de
>Environment:
System: FreeBSD vran.herceg.de 4.3-STABLE FreeBSD 4.3-STABLE #6: Mon Jul 9 11:49:47 CEST 2001 root@vran.herceg.de:/vran/home/src/FreeBSD-4/src/sys/compile/VRAN i386

>Description:
	Under some circumstances, the symbolic link
	/proc/<anything>/file points to "unknown". In my experiments
	it seems that this is the case if a directory is created
	and/or removed in the as the executable and the executable is
	called with a relative path. Some of the sysctl variables
	vfs.cache.numfullpathfail[1-4] are increased.

	This problem causes one test failure in perl5.7.3.

>How-To-Repeat:
	Compile the program below:
----------------------------------------------------------------------
#include <unistd.h>
main() {
  char buf[1024];
  int len = readlink("/proc/curproc/file", buf, 1024);
  if (!len) exit(1);
  buf[len]=0;
  printf("<%s>\n", buf);
}
----------------------------------------------------------------------
	If run as ./a.out, it works OK.
	However, if a subdirectory in the same directory is deleted,
	then the program returns "unknown":

		mkdir foo ; rmdir foo ; ./a.out

	This works again:

		mkdir foo ; rmdir foo ; `pwd`/a.out

>Fix:

	???
>Release-Note:
>Audit-Trail:

From: David Malone <dwmalone@maths.tcd.ie>
To: Slaven Rezic <slaven.rezic@berlin.de>
Cc: FreeBSD-gnats-submit@freebsd.org
Subject: Re: kern/35703: /proc/curproc/file returns unknown
Date: Sat, 9 Mar 2002 13:36:00 +0000

 On Sat, Mar 09, 2002 at 12:28:07PM +0100, Slaven Rezic wrote:
 > 	If run as ./a.out, it works OK.
 > 	However, if a subdirectory in the same directory is deleted,
 > 	then the program returns "unknown":
 > 
 > 		mkdir foo ; rmdir foo ; ./a.out
 > 
 > 	This works again:
 > 
 > 		mkdir foo ; rmdir foo ; `pwd`/a.out
 
 This is the same problem which sometimes caused the Linux emulators
 getcwd to fail. The linux emulation code has since been fixed to
 try harder, as Linux applications expect it to.
 
 I'm not sure that people would be in favour of making procfs try
 harder, as procfs doesn't even have to be mounted for most things
 in FreeBSD now. If you did want to try and fix it, then the place
 to start looking would be at the Linux emulation getcwd code in
 /usr/src/sys/compat/linux/linux_getcwd.c.
 
 	David.
State-Changed-From-To: open->closed 
State-Changed-By: kmacy 
State-Changed-When: Fri Nov 16 02:45:20 UTC 2007 
State-Changed-Why:  

A bug in a subsystem that is deprecated. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=35703 
>Unformatted:
FreeBSD's procfs is deprecated.
