Kernel 2.2.13 breaks JNI on ix86, /proc/01234 weirdness

Greg Wolodkin (greg@mathworks.com)
Sat, 30 Oct 1999 21:51:51 -0400


Hi all -
After upgrading my Linux kernel from 2.2.12 to 2.2.13, Java JNI
examples fail to load the virtual machine *if* the process number
is below 10000.

I'm not sure whether or not this is a bug in the 2.2.13 kernel, or a
bug in the Blackdown JDK (1.1.7 v1a,v3), but the error I see when
starting the VM is "Cannot open /proc/09640 for GC" where 9640 is the
process ID of the guy who's trying to start the VM.

A simpler C program which reliably illustrates the same behavior is this:

#include <stdio.h>
void main(void) { if (fopen("/proc/00001","r") == NULL) printf("Oops.\n"); }

where in 2.2.12 and before, /proc/00001 would map to /proc/1. In
2.2.13 that's no longer true.

Backing out these two patches (below) fixes the problem, but I'm
wondering where the bug is (kernel or JDK) and what is the right fix?
The 1.2 JDK from Blackdown doesn't seem to have this problem, so
maybe the correct answer is a bug in the 1.1.7 JDK? A quick scan of
the proc man page didn't reveal any details as to whether or not I
should be able to open /proc/00001 instead of /proc/1.

Either way, I hope this simple example helps -- Thanks!
Greg

diff -u --recursive --new-file v2.2.12/linux/fs/proc/fd.c linux/fs/proc/fd.c
--- v2.2.12/linux/fs/proc/fd.c Fri Apr 23 21:20:38 1999
+++ linux/fs/proc/fd.c Tue Oct 19 17:14:02 1999
@@ -87,6 +87,7 @@
fd = 0;
len = dentry->d_name.len;
name = dentry->d_name.name;
+ if (len > 1 && *name == '0') goto out;
while (len-- > 0) {
c = *name - '0';
name++;
diff -u --recursive --new-file v2.2.12/linux/fs/proc/root.c linux/fs/proc/root.c
--- v2.2.12/linux/fs/proc/root.c Mon Aug 9 16:05:57 1999
+++ linux/fs/proc/root.c Tue Oct 19 17:14:02 1999
@@ -845,6 +845,7 @@
}
pid *= 10;
pid += c;
+ if (!pid) break;
if (pid & 0xffff0000) {
pid = 0;
break;

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/