Subject: kern/35368: Sun JDK 1.5.0 stopped working with -current kernel
To: None <kern-bug-people@netbsd.org, gnats-admin@netbsd.org,>
From: Brian de Alwis <bsd@cs.ubc.ca>
List: netbsd-bugs
Date: 01/06/2007 19:20:00
>Number:         35368
>Category:       kern
>Synopsis:       Sun JDK 1.5.0 stopped working with -current kernel
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 06 19:20:00 +0000 2007
>Originator:     Brian de Alwis
>Release:        NetBSD 4.99.5
>Organization:
  Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
      "Amusement to an observing mind is study." - Benjamin Disraeli
>Environment:
System: NetBSD monolith 4.99.7 NetBSD 4.99.7 (GENERIC.MPACPI) #0: Sat Jan  6 13:02:49 CST 2007 bsd@monolith:/usr/obj/sys/arch/i386/compile/GENERIC.MPACPI i386
Architecture: i386
Machine: i386
>Description:
	The Sun JDK 1.5.0 stopped working on -current with sources from Dec 15
	<http://mail-index.netbsd.org/current-users/2006/12/15/0007.html>,
	complaining:

	    $ java
	    Error: could not find libjava.so
	    Error: could not find Java 2 Runtime Environment.
	    $

	This is still the case on -current, as updated on 2007/01/06.

	Christos Zoulas and George Michaelson narrowed down the
	problem to readlink returning 1
	<http://mail-index.netbsd.org/pkgsrc-users/2006/12/18/0012.html>:

  1022      1 java     RET   __sysctl 0
  1022      1 java     CALL  brk(0)
  1022      1 java     RET   brk 134582272/0x8059000
  1022      1 java     CALL  brk(0x807a000)
  1022      1 java     RET   brk 134717440/0x807a000
  1022      1 java     CALL  readlink(0x80555e1,0xbfbfb2c0,0xfff)
  1022      1 java     NAMI  "/emul/linux/proc/self/exe"
  1022      1 java     NAMI  "/emul/linux"
  1022      1 java     NAMI  "/emul/linux/proc/self/exe"
  1022      1 java     RET   readlink 1
  1022      1 java     CALL  write(2,0x80558c0,0x21)
  1022      1 java     GIO   fd 2 wrote 33 bytes
       "Error: could not find libjava.so
       "

	This is as compared to the following trace from a correctly
	functioning Java, executed on a kernel from 2006/12/04:

   850      1 java     CALL  __sysctl(0xbfbfdb24)
   850      1 java     RET   __sysctl 0
   850      1 java     CALL  brk(0)
   850      1 java     RET   brk 134582272/0x8059000
   850      1 java     CALL  brk(0x807a000)
   850      1 java     RET   brk 134717440/0x807a000
   850      1 java     CALL  readlink(0x80555e1,0xbfbfadf0,0xfff)
   850      1 java     NAMI  "/emul/linux/proc/self/exe"
   850      1 java     NAMI  "/emul/linux"
   850      1 java     NAMI  "/emul/linux/proc/self/exe"
   850      1 java     RET   readlink 30/0x1e
   850      1 java     CALL  access(0xbfbfadf0,0)
   850      1 java     NAMI  "/emul/linux/usr/pkg/java/sun-1.5/lib/i386/libjava.so"
   850      1 java     NAMI  "/usr/pkg/java/sun-1.5/lib/i386/libjava.so"
   850      1 java     RET   access 0
   850      1 java     CALL  open(0xbfbfadd0,0,0x1b6)
   850      1 java     NAMI  "/emul/linux/usr/pkg/java/sun-1.5/lib/i386/jvm.cfg"
   850      1 java     NAMI  "/usr/pkg/java/sun-1.5/lib/i386/jvm.cfg"
   850      1 java     RET   open 3

	Christos asked
	<http://mail-index.netbsd.org/pkgsrc-users/2006/12/18/0012.html>:
	> Also if you can ^Z the java process before it exits,
	> you can cd to /emul/linux/proc/<java-pid> and ls -l exe and see what
	> it says.

$ gdb /usr/pkg/java/sun-1.5/bin/java
[...]
(gdb) br readlink 
Breakpoint 1 at 0x8048f18
(gdb) run
Starting program: /usr/pkg/java/sun-1.5/bin/java 
warning: no shared library support for this OS / ABI

Breakpoint 1, 0x08048f18 in readlink@plt ()
(gdb) 
[1]+  Stopped                 gdb /usr/pkg/java/sun-1.5/bin/java
$ ps x | g java
 707 ttyp2 T    0:00.01 gdb /usr/pkg/java/sun-1.5/bin/java 
4151 ttyp2 TX   0:00.00 /usr/pkg/java/sun-1.5/bin/java 
$ ls -l /proc/4151
total 289
-r--r--r--  1 bsd   users       0 Jan  6 12:12 cmdline
--w-------  1 bsd   users       0 Jan  6 12:12 ctl
lr-xr-xr-x  1 root  wheel       9 Jan  6 12:12 cwd@ -> /home/bsd
-r--r--r--  1 bsd   users       5 Jan  6 12:12 emul
lr-xr-xr-x  1 root  wheel       1 Jan  6 12:12 exe@ -> /
dr-x------  2 bsd   users     512 Jan  6 12:12 fd/
-rwxr-xr-x  1 root  wheel   65076 Jul 19 15:53 file*
-rw-------  1 bsd   users     108 Jan  6 12:12 fpregs
-r--r--r--  1 bsd   users       0 Jan  6 12:12 map
-r--r--r--  1 bsd   users       0 Jan  6 12:12 maps
-rw-------  1 bsd   users  229376 Jan  6 12:12 mem
--w-------  1 bsd   users       0 Jan  6 12:12 note
--w-------  1 bsd   users       0 Jan  6 12:12 notepg
-rw-------  1 bsd   users      64 Jan  6 12:12 regs
lr-xr-xr-x  1 root  wheel       1 Jan  6 12:12 root@ -> /
-r--r--r--  1 bsd   users       0 Jan  6 12:12 status
-rw-------  1 bsd   users     512 Jan  6 12:12 xmmregs
$

	This was executed as a normal user.

>How-To-Repeat:
	1. Compile a kernel from -current.
        2. Install lang/sun-jdk15 from pkgsrc.
	3. Run javac.  See the error message about being unable to load
	   libjava.so

>Fix:
	By applying change by change from Dec 5, this bug appears
	to have been introduced by the fix to kern/35143.  If it
	helps, the files affected were:

+++ coda/coda_vfsops.c	9 Dec 2006 16:11:50 -0000	1.53
+++ coda/coda_vnops.c	9 Dec 2006 16:11:50 -0000	1.51
+++ fs/adosfs/adlookup.c	9 Dec 2006 16:11:50 -0000	1.9
+++ fs/cd9660/cd9660_lookup.c	9 Dec 2006 16:11:50 -0000	1.12
+++ fs/filecorefs/filecore_lookup.c	9 Dec 2006 16:11:51 -0000	1.8
+++ fs/filecorefs/filecore_vfsops.c	9 Dec 2006 16:11:51 -0000	1.29
+++ fs/msdosfs/msdosfs_lookup.c	9 Dec 2006 16:11:51 -0000	1.11
+++ fs/msdosfs/msdosfs_vnops.c	9 Dec 2006 16:11:51 -0000	1.35
+++ fs/ntfs/ntfs.h	9 Dec 2006 16:11:51 -0000	1.15
+++ fs/ntfs/ntfs_vnops.c	9 Dec 2006 16:11:51 -0000	1.31
+++ fs/ptyfs/ptyfs_vfsops.c	9 Dec 2006 16:11:51 -0000	1.22
+++ fs/ptyfs/ptyfs_vnops.c	9 Dec 2006 16:11:51 -0000	1.19
+++ fs/puffs/puffs_vfsops.c	9 Dec 2006 16:11:51 -0000	1.15
+++ fs/puffs/puffs_vnops.c	9 Dec 2006 16:11:51 -0000	1.22
+++ fs/smbfs/smbfs_vfsops.c	9 Dec 2006 16:11:51 -0000	1.61
+++ fs/smbfs/smbfs_vnops.c	9 Dec 2006 16:11:51 -0000	1.57
+++ fs/sysvbfs/sysvbfs.c	9 Dec 2006 16:11:51 -0000	1.3
+++ fs/sysvbfs/sysvbfs_vnops.c	9 Dec 2006 16:11:51 -0000	1.6
+++ fs/tmpfs/tmpfs_vnops.c	9 Dec 2006 16:11:51 -0000	1.33
+++ fs/udf/udf_vnops.c	9 Dec 2006 16:11:51 -0000	1.8
+++ fs/union/union_subr.c	9 Dec 2006 16:11:51 -0000	1.22
+++ fs/union/union_vfsops.c	9 Dec 2006 16:11:51 -0000	1.41
+++ fs/union/union_vnops.c	9 Dec 2006 16:11:51 -0000	1.18
+++ kern/vfs_cache.c	9 Dec 2006 16:11:51 -0000	1.67
+++ kern/vfs_getcwd.c	9 Dec 2006 16:11:51 -0000	1.34
+++ kern/vfs_lookup.c	9 Dec 2006 16:11:51 -0000	1.73
+++ kern/vfs_syscalls.c	9 Dec 2006 16:11:51 -0000	1.280
+++ miscfs/deadfs/dead_vnops.c	9 Dec 2006 16:11:51 -0000	1.42
+++ miscfs/fdesc/fdesc_vfsops.c	9 Dec 2006 16:11:52 -0000	1.63
+++ miscfs/fdesc/fdesc_vnops.c	9 Dec 2006 16:11:52 -0000	1.95
+++ miscfs/genfs/layer_subr.c	9 Dec 2006 16:11:52 -0000	1.21
+++ miscfs/genfs/layer_vnops.c	9 Dec 2006 16:11:52 -0000	1.29
+++ miscfs/kernfs/kernfs_vfsops.c	9 Dec 2006 16:11:52 -0000	1.75
+++ miscfs/kernfs/kernfs_vnops.c	9 Dec 2006 16:11:52 -0000	1.129
+++ miscfs/portal/portal_vfsops.c	9 Dec 2006 16:11:52 -0000	1.59
+++ miscfs/portal/portal_vnops.c	9 Dec 2006 16:11:52 -0000	1.69
+++ miscfs/procfs/procfs_vfsops.c	9 Dec 2006 16:11:52 -0000	1.68
+++ miscfs/procfs/procfs_vnops.c	9 Dec 2006 16:11:52 -0000	1.143
+++ miscfs/umapfs/umap_vnops.c	9 Dec 2006 16:11:52 -0000	1.43
+++ nfs/nfs_export.c	9 Dec 2006 16:11:52 -0000	1.23
+++ nfs/nfs_serv.c	9 Dec 2006 16:11:52 -0000	1.120
+++ nfs/nfs_subs.c	9 Dec 2006 16:11:52 -0000	1.178
+++ nfs/nfs_vnops.c	9 Dec 2006 16:11:52 -0000	1.246
+++ sys/namei.h	9 Dec 2006 16:11:52 -0000	1.46
+++ ufs/ext2fs/ext2fs_lookup.c	9 Dec 2006 16:11:52 -0000	1.47
+++ ufs/ext2fs/ext2fs_vnops.c	9 Dec 2006 16:11:52 -0000	1.70
+++ ufs/lfs/lfs_vnops.c	9 Dec 2006 16:11:52 -0000	1.194
+++ ufs/ufs/ufs_extattr.c	9 Dec 2006 16:11:52 -0000	1.11
+++ ufs/ufs/ufs_lookup.c	9 Dec 2006 16:11:52 -0000	1.81
+++ ufs/ufs/ufs_vnops.c	9 Dec 2006 16:11:52 -0000	1.144
+++ uvm/uvm_vnode.c	9 Dec 2006 16:11:52 -0000	1.78

-- 
  Brian de Alwis | Software Practices Lab | UBC | http://www.cs.ubc.ca/~bsd/
      "Amusement to an observing mind is study." - Benjamin Disraeli