From owner-freebsd-hackers@FreeBSD.ORG Thu Nov 13 10:49:01 2014 Return-Path: Delivered-To: hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6F36C7A3 for ; Thu, 13 Nov 2014 10:49:01 +0000 (UTC) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2on0096.outbound.protection.outlook.com [207.46.100.96]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 37A66805 for ; Thu, 13 Nov 2014 10:49:00 +0000 (UTC) Received: from DM2PR04MB477.namprd04.prod.outlook.com (10.141.105.13) by DM2PR04MB479.namprd04.prod.outlook.com (10.141.105.21) with Microsoft SMTP Server (TLS) id 15.1.16.15; Thu, 13 Nov 2014 10:33:47 +0000 Received: from DM2PR04MB477.namprd04.prod.outlook.com ([169.254.15.59]) by DM2PR04MB477.namprd04.prod.outlook.com ([169.254.15.59]) with mapi id 15.01.0016.006; Thu, 13 Nov 2014 10:33:47 +0000 From: Mike Gelfand To: "hackers@freebsd.org" Subject: [BUG] Getting path to program binary sometimes fails Thread-Topic: [BUG] Getting path to program binary sometimes fails Thread-Index: AQHP/y1OF6HbydE23kCBwyNP5wFRKQ== Date: Thu, 13 Nov 2014 10:33:47 +0000 Message-ID: <91809230-5E81-4A6E-BFD6-BE8815A06BB2@logicnow.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [128.140.241.14] x-microsoft-antispam: BCL:0;PCL:0;RULEID:;SRVR:DM2PR04MB479; x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:;SRVR:DM2PR04MB479; x-forefront-prvs: 0394259C80 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(71364002)(189002)(15202345003)(15395725005)(46102003)(19273905006)(83716003)(54356999)(21056001)(64706001)(92726001)(97736003)(92566001)(87936001)(2656002)(50986999)(4396001)(31966008)(66066001)(20776003)(15975445006)(82746002)(101416001)(33656002)(19300405004)(86362001)(110136001)(229853001)(19580395003)(122556002)(2351001)(107886001)(99396003)(105586002)(36756003)(450100001)(99286002)(107046002)(77096003)(2501002)(77156002)(40100003)(62966003)(106356001)(95666004)(120916001)(106116001)(104396001)(562404015)(85282002)(563064011); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR04MB479; H:DM2PR04MB477.namprd04.prod.outlook.com; FPR:; MLV:sfv; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Content-Type: text/plain; charset="Windows-1252" Content-ID: <32E5664FD0405142AB9C77883A046CC5@namprd04.prod.outlook.com> Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: logicnow.com X-Mailman-Approved-At: Thu, 13 Nov 2014 12:20:34 +0000 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 Nov 2014 10:49:01 -0000 Hello, I=92ve been advised (on #freebsd @FreeNode) to send a mail here with detail= s. I=92m observing a weird issue where process may not able to determine path = to its own binary (and maybe other process binaries as well, thought I didn= =92t test that) under some [not yet clear to me] conditions. The code I use= in production first tries to call sysctl(KERN_PROC_PATHNAME) and if that f= ails fallback to call readlink(/proc/curproc/file); at some point both call= s fail with ENOENT. This happens on two FreeBSD 9 (vanilla 9.1-RELEASE and = 9.2-RELEASE) machines, and never happens (or at least never happened in ove= r two years) on FreeBSD 8 (vanilla 8.3-RELEASE-p3); all machines are amd64.= I=92ve been able to reduce the test case to a sample program [1] which I r= un using a sample script [2], and the error then happens when I=92m buildin= g clang-devel from ports. I=92ve also recorded a screencast [3]. Is this a know defect? Do you need any other information other than provide= d above to reproduce? [1] http://mikedld.com/f/selfpath/selfpath.c [2] http://mikedld.com/f/selfpath/selfpath.sh [3] http://mikedld.com/f/selfpath/selfpath.mov Kind regards, Mike