java - Why doesn't dtruss show me the select system call in this JNI code? -
while investigating jdk bug on mac os, ran system call trace output don't understand:
tomcat startup fails due 'java.net.socketexception invalid argument' on mac os x
the short version: on mac os, jdk uses select()
instead of poll()
. so, if more 1024 file descriptors allocated, deduced select()
call in net_timeout
fails resulting in socketexception 'invalid argument' message. however, when traced system calls, saw no evidence of select()
system call, or call fails , sets einval, discounted potential cause.
i don't see call reduced test case i've created understand problem:
import java.io.*; import java.net.*; public class selecttest { public static void main(string[] args) throws exception { for(int = 0; < 1024; i++) { new fileinputstream("/dev/null"); } serversocket socket = new serversocket(8080); socket.accept(); } }
results in exception on mac os w/ jdk 1.7u5 , later:
exception in thread "main" java.net.socketexception: invalid argument @ java.net.plainsocketimpl.socketaccept(native method) @ java.net.abstractplainsocketimpl.accept(abstractplainsocketimpl.java:398) @ java.net.serversocket.implaccept(serversocket.java:522) @ java.net.serversocket.accept(serversocket.java:490) @ selecttest.main(selecttest.java:12)
why don't see evidence of select()
(or other failing) call when run test using sudo dtruss -a java selecttest
?
pid/thrd relative elapsd cpu syscall(args) = return 45563/0x63a513: 85544 6 4 bind(0x412, 0x10dfc7738, 0x1c) = 0 0 45563/0x63a513: 85605 6 3 listen(0x412, 0x32, 0x32) = 0 0 45563/0x63a513: 85619 2 0 lseek(0x4, 0x37377ad, 0x0) = 57898925 0 45563/0x63a513: 85622 4 2 read(0x4, "pk\003\004\n\0", 0x1e) = 30 0 45563/0x63a513: 85622 1 0 lseek(0x4, 0x37377e0, 0x0) = 57898976 0 45563/0x63a513: 85627 5 4 read(0x4, "\312\376\272\276\0", 0x3447) = 13383 0 45563/0x63a513: 86150 37 33 write(0x2, "exception in thread \"main\" ble\001\0", 0x1b) = 27 0
i expect serversocket.accept
call saw.
the berkeley sockets calls corresponding java's accept
listen() , accept()
unfortunately i'm unable reproduce exception on linux. if use fd's before new serversocket(8080)
get:
exception in thread "main" java.lang.unsatisfiedlinkerror: /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnet.so: /usr/lib/jvm/java-7-oracle/jre/lib/amd64/libnet.so: cannot open shared object file: many open files @ java.lang.classloader$nativelibrary.load(native method) @ java.lang.classloader.loadlibrary1(classloader.java:1939) @ java.lang.classloader.loadlibrary0(classloader.java:1864) @ java.lang.classloader.loadlibrary(classloader.java:1846) @ java.lang.runtime.loadlibrary0(runtime.java:845) @ java.lang.system.loadlibrary(system.java:1084) @ sun.security.action.loadlibraryaction.run(loadlibraryaction.java:67) @ sun.security.action.loadlibraryaction.run(loadlibraryaction.java:47) @ java.security.accesscontroller.doprivileged(native method) @ java.net.abstractplainsocketimpl.<clinit>(abstractplainsocketimpl.java:80) @ java.net.serversocket.setimpl(serversocket.java:289) @ java.net.serversocket.<init>(serversocket.java:230) @ java.net.serversocket.<init>(serversocket.java:128) @ selecttest.main(selecttest.java:15)
Comments
Post a Comment