Date: Tue, 29 Jan 2013 12:47:39 -0800 From: Phil Phillips <pphillips@experts-exchange.com> To: freebsd-java@freebsd.org Subject: OpenJDK7: libnet.so getting closed twice Message-ID: <5108356B.1060008@experts-exchange.com>
next in thread | raw e-mail | index | archive | help
Hey all, I have some code running on the latest version of OpenJDK7. In one thread, it opens a ServerSocket. In another, it loads a configuration file. Once in a while, the config file fails to load with: Caused by: java.io.FileNotFoundException: global.properties (Bad file descriptor) at java.io.FileInputStream.open(Native Method) at java.io.FileInputStream.<init>(FileInputStream.java:138) at java.io.FileInputStream.<init>(FileInputStream.java:97) at java.io.FileReader.<init>(FileReader.java:58) Digging in a little deeper with truss, I see something like: open("/usr/local/openjdk7/jre/lib/amd64/libnet.so",O_RDONLY,01) = 63 (0x3f) close(63) = 0 (0x0) close(63) ERR#9 'Bad file descriptor'\ ... open("global.properties",O_RDONLY,00) = 63 (0x3f) fstat(63,{ mode=-rw-rw-r-- ,inode=32200398,size=18260,blksize=16384 }) = 0 (0x0) fcntl(63,F_GETFD,) libnet.so is getting opened (interestingly, not read - though it was read previously) and then closed *twice*. It looks like there's a race condition that can cause the "bad file descriptor" error if: 1) libnet.so opened 2) libnet.so closed (1st time) 3) config file opened (inherits now-free file descriptor) 4) libnet.so closed (2nd time - invalidates file descriptor for config file) I don't see this kind of behavior in OpenJDK6. Does anyone know what might cause libnet.so to be closed twice in OpenJDK7? Thanks, Phil
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5108356B.1060008>