I'm coding a multithreaded java program where threads do mainly two things:
some of them open an HTTPS connection (with a custom X509TrustManager), other
execute a shell script (through Runtime.exec).
I noticed that often the JVM hangs during the fork process (caused by
Runtime.exec), and the jstack of the forked JVM process is always the same:
----------------- [EMAIL PROTECTED] -----------------
0xff340408 __lwp_park + 0x10
0xff339068 mutex_lock_internal + 0x5d0
0xfb08a2ec soft_delete_session + 0xf0
0xfb089f90 soft_delete_all_sessions + 0x4c
0xfb084348 finalize_common + 0x70
0xfb0844d8 softtoken_fini + 0x44
0xfb0d8d48 _fini + 0x4
0xff3c00d0 call_fini + 0xc8
0xff3ca614 remove_hdl + 0xab8
0xff3c4d54 dlclose_intn + 0x98
0xff3c4e68 dlclose + 0x5c
0xfb3a2b3c pkcs11_slottable_delete + 0x138
0xfb39d664 pkcs11_fini + 0x4c
0xff2c0ea0 _postfork_child_handler + 0x30
0xff332c20 fork + 0x140
0xfe8f8df4 Java_java_lang_UNIXProcess_forkAndExec + 0x7d4
0xf9226020 0xf9226020 * java.lang.UNIXProcess.forkAndExec(byte[],
byte[], int, byte[], int, byte[], boolean, java.io.FileDescriptor,
java.io.FileDescriptor, java.io.FileDescriptor) bci:0 (Compiled frame;
information may be imprecise)
0xf92216c4 0xf92216c4 * java.lang.UNIXProcess.<init>(byte[], byte[],
int, byte[], int, byte[], boolean) bci:62 line:53 (Compiled frame)
0xf90fa6b8 0xf90fa6b8 *
java.lang.ProcessImpl.start(java.lang.String[], java.util.Map,
java.lang.String, boolean) bci:182 line:65 (Compiled frame)
0xf90fbe0c 0xf90fbe0c * java.lang.ProcessBuilder.start() bci:112
line:451 (Compiled frame)
0xf921842c 0xf921842c * java.lang.Runtime.exec(java.lang.String[],
java.lang.String[], java.io.File) bci:16 line:591 (Compiled frame)
0xf9005874 * java.lang.Runtime.exec(java.lang.String[]) bci:4 line:464
(Interpreted frame)
0xf9005874 * TestExec.run() bci:26 line:22 (Interpreted frame)
0xf9005c2c * java.lang.Thread.run() bci:11 line:595 (Interpreted frame)
0xf9000218 <StubRoutines>
0xfecdca88 void
JavaCalls::call_helper(JavaValue*,methodHandle*,JavaCallArguments*,Thread*) +
0x5b8
0xfecf4310 void
JavaCalls::call_virtual(JavaValue*,Handle,KlassHandle,symbolHandle,symbolHandle,Thread*)
+ 0x18c
0xfecf416c void thread_entry(JavaThread*,Thread*) + 0x12c
0xfecf3ff0 void JavaThread::run() + 0x1f4
0xff02fb30 void*_start(void*) + 0x200
0xff340368 _lwp_start
I wonder: could it be a deadlock in soft_delete_session, at line 299 of
softSessionUtil.c:
(void) pthread_mutex_lock(&session_p->session_mutex);
Also, could it be a bug of the jvm or the operating system?
This happens with any jvm from 1.4 to 1.6, but only on solaris.
Anyway, can anyone suggest me any other ways to investigate?
I'm not yet able to supply a testcase because my java code is still too long
and complex, i'm trying to isolate the code which causes this lock.
The problem seems to disappear when:
1) i disable the solaris cryptosrvc, or
2) when i remove the following java code:
TrustManager[] trustAllCerts = new TrustManager[] {new X509TrustManager() {
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(java.security.cert.X509Certificate[]
certs, String authType) {
}
public void checkServerTrusted(java.security.cert.X509Certificate[]
certs, String authType) {
}
}
};
try {
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, new java.security.SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String s1, SSLSession s2) {
return true;
}
}
);
}catch(Exception e){}
Indeed by removing this code, the JVM is NOT anymore linked to
/usr/lib/security/pkcs11_softtoken.so.1
Otherwise, with the above code included, the pldd of the java process is the
following:
/lib/libthread.so.1
/lib/libdl.so.1
/lib/libc.so.1
/platform/sun4u/lib/libc_psr.so.1
/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/client/libjvm.so
/lib/libsocket.so.1
/usr/lib/libsched.so.1
/usr/lib/libCrun.so.1
/lib/libm.so.1
/lib/libnsl.so.1
/lib/libm.so.2
/lib/libscf.so.1
/lib/libdoor.so.1
/lib/libuutil.so.1
/lib/libmd5.so.1
/platform/sun4u/lib/libmd5_psr.so.1
/lib/libmp.so.2
/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/native_threads/libhpi.so
/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/libverify.so
/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/libjava.so
/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/libzip.so
/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/libj2pkcs11.so
/usr/lib/libpkcs11.so.1
/usr/lib/libcryptoutil.so.1
/usr/lib/security/pkcs11_softtoken.so.1
/usr/jdk/instances/jdk1.5.0/jre/lib/sparc/libnet.so
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code