From owner-freebsd-java@FreeBSD.ORG Mon Aug 15 22:57:47 2011 Return-Path: Delivered-To: freebsd-java@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 5A5D8106564A; Mon, 15 Aug 2011 22:57:47 +0000 (UTC) (envelope-from bf1783@googlemail.com) Received: from mail-pz0-f45.google.com (mail-pz0-f45.google.com [209.85.210.45]) by mx1.freebsd.org (Postfix) with ESMTP id 2492D8FC13; Mon, 15 Aug 2011 22:57:46 +0000 (UTC) Received: by pzk33 with SMTP id 33so6068655pzk.18 for ; Mon, 15 Aug 2011 15:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=H7SUOyoEGUK6L14/qIrEm5S/Wd3nKUXxo7FLdxT0SFM=; b=eAyjoG37ef6K356rT2qkcboMnyxhwFTKkoCadv3copO6GiQI6fp7ExKG+F11DMfU52 i3yPAjMsIO/KTc9oQbawiVXWnXmo6/E2WsuIu2kktuZ5DSf9cPCpKA3pxWDAo8slVE1s mK0Prp1UJo2mMErPyW6wIVHzeAYKdD7RVC24E= MIME-Version: 1.0 Received: by 10.142.166.11 with SMTP id o11mr2158981wfe.170.1313449066598; Mon, 15 Aug 2011 15:57:46 -0700 (PDT) Received: by 10.68.66.106 with HTTP; Mon, 15 Aug 2011 15:57:46 -0700 (PDT) In-Reply-To: <20110812150000.GA2588@misty.eyesbeyond.com> References: <20110812113704.GO17489@deviant.kiev.zoral.com.ua> <20110812150000.GA2588@misty.eyesbeyond.com> Date: Mon, 15 Aug 2011 18:57:46 -0400 Message-ID: From: "b. f." To: Greg Lewis Content-Type: text/plain; charset=ISO-8859-1 Cc: Kostik Belousov , glewis@freebsd.org, tinderbox-list@marcuscom.com, des@freebsd.org, freebsd-java@freebsd.org Subject: Re: java + procfs + nullfs = disaster X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: bf1783@gmail.com List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Aug 2011 22:57:47 -0000 On 8/12/11, Greg Lewis wrote: > On Fri, Aug 12, 2011 at 02:37:04PM +0300, Kostik Belousov wrote: >> On Thu, Aug 11, 2011 at 03:18:38PM -0400, b. f. wrote: >> > I've run into a problem building java ports on my FreeBSD 9 amd64 >> > tinderbox. Following an earlier suggestion, >> > >> > http://www.marcuscom.com/pipermail/tinderbox-list/2010-September/001957.html >> > >> > I've been performing builds in a tmpfs that is nullfs-mounted on a ufs >> > mountpoint. After building packages for java/diablo-jdk16 on >> > {7.3,8.1}-{i386,amd64}, the ports that depend upon it fail when >> > invoking java binary executables from that port, with: >> > >> > Error: could not find libjava.so >> > Error: could not find Java 2 Runtime Environment. >> > >> > A search of the mailing lists reveals that this problem has occurred >> > for the past several years, and has sometimes been attributed to the >> > fact that a procfs is mounted on /proc, and sometimes to vague nullfs >> > problems, but has never been solved: >> > >> > http://lists.freebsd.org/pipermail/freebsd-java/2011-March/009169.html >> > http://lists.freebsd.org/pipermail/freebsd-stable/2010-May/056814.html >> > http://lists.freebsd.org/pipermail/freebsd-java/2009-May/008104.html >> > http://lists.freebsd.org/pipermail/freebsd-java/2009-February/007854.html >> > http://lists.freebsd.org/pipermail/freebsd-stable/2005-February/011629.html >> > ... >> > >> > However, it seems rather to be a combination of factors, because, for >> > example, if I: >> > >> > mount /proc >> > mkdir /tmp/java >> > tar -C /tmp/java -xvf >> > /home/shared/freebsd/tinderbox/packages/8.1-amd64-u1/All/diablo-jdk-1.6.0.07.02_15.tbz >> > cd /tmp/diablo-jdk1.6.0/bin >> > truss ./java -version >> > >> > , I obtain: >> > >> > ... >> > >> > readlink("/proc/curproc/file","/tmp/java/diablo-jdk1.6.0/bin/java",1024) >> > = 35 (0x23) >> > access("/tmp/java/diablo-jdk1.6.0/lib/amd64/libjava.so",0) ERR#2 'No >> > such file or directory' >> > access("/tmp/java/diablo-jdk1.6.0/jre/lib/amd64/libjava.so",0) = 0 (0x0) >> > >> > ... >> > >> > , and libjava.so is found. Then, if I: >> > >> > umount /proc >> > truss ./java -version >> > >> > , the library is also found, in a slightly different manner: >> > >> > +readlink("/proc/curproc/file",0x7fffffffca40,1024) ERR#2 'No such >> > file or directory' >> > +__getcwd("/tmp/java/diablo-jdk1.6.0/bin",1026) = 0 (0x0) >> > +stat("/tmp/java/diablo-jdk1.6.0/bin/./java",{ mode=-rwxr-xr-x >> > ,inode=3121,size=95014,blksize=4096 }) = 0 (0x0) >> > +lstat("/tmp",{ mode=drwxrwxrwt ,inode=2,size=600,blksize=4096 }) = 0 >> > (0x0) >> > +lstat("/tmp/java",{ mode=drwxr-xr-x ,inode=15,size=280,blksize=4096 >> > }) = 0 (0x0) >> > +lstat("/tmp/java/diablo-jdk1.6.0",{ mode=drwxr-xr-x >> > ,inode=3105,size=560,blksize=4096 }) = 0 (0x0) >> > +lstat("/tmp/java/diablo-jdk1.6.0/bin",{ mode=drwxr-xr-x >> > ,inode=3112,size=1720,blksize=4096 }) = 0 (0x0) >> > +lstat("/tmp/java/diablo-jdk1.6.0/bin/java",{ mode=-rwxr-xr-x >> > ,inode=3121,size=95014,blksize=4096 }) = 0 (0x0) >> > access("/tmp/java/diablo-jdk1.6.0/lib/amd64/libjava.so",0) ERR#2 'No >> > such file or directory' >> > access("/tmp/java/diablo-jdk1.6.0/jre/lib/amd64/libjava.so",0) = 0 >> > (0x0) >> > >> > >> > However, if I: >> > >> > rm -vr /tmp/java >> > mount /proc >> > mkdir /tmp/java /root/java >> > mount -t nullfs /tmp/java /root/java >> > tar -C /root/java -xvf >> > /home/shared/freebsd/tinderbox/packages/8.1-amd64-u1/All/diablo-jdk-1.6.0.07.02_15.tbz >> > cd /root/diablo-jdk1.6.0/bin >> > truss ./java -version >> > >> > then the library cannot be found: >> > >> > readlink("/proc/curproc/file","unknown",1024) = 7 (0x7) >> > Error: could not find libjava.so >> > write(2,"Error: could not find libjava.so"...,33) = 33 (0x21) >> > Error: could not find Java 2 Runtime Environment. >> > write(2,"Error: could not find Java 2 Run"...,50) = 50 (0x32) >> This is a long-standing strangeness in our procfs. I wonder how much >> will break after the following. Can you try ls -l /proc// >> in the situation when file previously shown 'unknown' ? >> >> diff --git a/sys/fs/procfs/procfs.c b/sys/fs/procfs/procfs.c >> index 8b69eb1..514e279 100644 >> --- a/sys/fs/procfs/procfs.c >> +++ b/sys/fs/procfs/procfs.c >> @@ -67,20 +67,23 @@ >> int >> procfs_doprocfile(PFS_FILL_ARGS) >> { >> - char *fullpath = "unknown"; >> - char *freepath = NULL; >> + char *fullpath; >> + char *freepath; >> struct vnode *textvp; >> + int error; >> >> + freepath = NULL; >> PROC_LOCK(p); >> textvp = p->p_textvp; >> vhold(textvp); >> PROC_UNLOCK(p); >> - vn_fullpath(td, textvp, &fullpath, &freepath); >> + error = vn_fullpath(td, textvp, &fullpath, &freepath); >> vdrop(textvp); >> - sbuf_printf(sb, "%s", fullpath); >> - if (freepath) >> + if (error == 0) >> + sbuf_printf(sb, "%s", fullpath); >> + if (freepath != NULL) >> free(freepath, M_TEMP); >> - return (0); >> + return (error); >> } >> >> /* Thank you, Kostik. After applying this patch, the java binary is able to locate its libraries in all of the cases above. Also, my tinderbox is able to build default java packages. The output of a ls -l /proc/... for a process involving a nullfs-mounted java is something like: # pgrep java 86219 # ls -l /proc/`pgrep java` total 0 -r--r--r-- 1 root wheel 0 Aug 15 18:26 cmdline --w------- 1 root wheel 0 Aug 15 18:26 ctl -rw------- 1 root wheel 0 Aug 15 18:26 dbregs -r--r--r-- 1 root wheel 0 Aug 15 18:26 etype ls: /proc/86219/file: No such file or directory lr--r--r-- 1 root wheel 0 Aug 15 18:26 file -rw------- 1 root wheel 0 Aug 15 18:26 fpregs -r--r--r-- 1 root wheel 0 Aug 15 18:26 map -rw------- 1 root wheel 0 Aug 15 18:26 mem --w------- 1 root wheel 0 Aug 15 18:26 note --w------- 1 root wheel 0 Aug 15 18:26 notepg -rw------- 1 root wheel 0 Aug 15 18:26 osrel -rw------- 1 root wheel 0 Aug 15 18:26 regs -r--r--r-- 1 root wheel 0 Aug 15 18:26 rlimit -r--r--r-- 1 root wheel 0 Aug 15 18:26 status Can we add these or equivalent changes to procfs for 9.0? Or would these changes violate some "unknown" convention? > > The other option here is to change the order in which the JDK detects where > it is and not try /proc as the first option. Unfortunately that won't > happen for Diablo since there is unlikely to be another release of that. > It can be changed for the build from source JDK ports though. I think that anything that can be done to make the detection process more robust would be appreciated, as it will be some time, if ever, before all supported versions of FreeBSD will have compatible procfs behavior. If Diablo remains unchanged, it will continue to cause problems, as it is the default bootstrap compiler. b.