JDK-6882426 : SSLSocket close causes SIGSEGV in pkcs11_softtoken.so.1
  • Type: Bug
  • Component: security-libs
  • Sub-Component: javax.net.ssl
  • Affected Version: 6u13
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2009-09-16
  • Updated: 2011-04-28
  • Resolved: 2011-04-28
Related Reports
Duplicate :  
Description
Digested from incident report http://webbugs.sfbay/rt/incidentDisplay?incidentID=1609753:

We occasionally encounter a SIGSEGV in pkcs11_softtoken.so.1 when closing an SSL socket.

The scenario: one thread is blocked on a read while another thread calls Socket.close(). The close causes the blocked thread to wake up and handle the resulting SocketException. It appears that both threads then simultaneously attempt to dispose of the SSL connection, causing pkcs11_softtoken.so.1`soft_decrypt_final to SIGSEGV.

Here is the thread dump of the two relevant threads from the core file:

$ jstack /app/java-1.6.0_13/bin/java core
Attaching to core core from executable /app/java-1.6.0_13/bin/java, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 11.3-b02
Deadlock Detection:

No deadlocks found.

Thread t@7486: (state = IN_NATIVE)
 - sun.security.pkcs11.wrapper.PKCS11.C_DecryptFinal(long, long, byte[], int, int) @bci=0 (Interpreted frame)
 - sun.security.pkcs11.P11Cipher.implDoFinal(byte[], int, int) @bci=97, line=511 (Interpreted frame)
 - sun.security.pkcs11.P11Cipher.engineDoFinal(byte[], int, int, byte[], int) @bci=44, line=425 (Interpreted frame)
 - sun.security.pkcs11.P11Cipher.engineDoFinal(byte[], int, int) @bci=16, line=409 (Interpreted frame)
 - javax.crypto.Cipher.doFinal() @bci=15 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.CipherBox.dispose() @bci=11, line=482 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(byte, java.lang.String, java.lang.Throwable) @bci=121, line=1622 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(byte, java.lang.Throwable) @bci=4, line=1574 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(java.lang.Exception, boolean) @bci=112, line=1538 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.SSLSocketImpl.handleException(java.lang.Exception) @bci=3, line=1483 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.AppInputStream.read(byte[], int, int) @bci=82, line=86 (Compiled frame)
 - java.io.InputStream.read(byte[]) @bci=5, line=85 (Interpreted frame)
 - com.tradingscreen.tunnel.api.TunnelPipe.run() @bci=59, line=76 (Compiled frame)


Thread t@7485: (state = IN_NATIVE)
 - sun.security.pkcs11.wrapper.PKCS11.C_DecryptFinal(long, long, byte[], int, int) @bci=0 (Interpreted frame)
 - sun.security.pkcs11.P11Cipher.implDoFinal(byte[], int, int) @bci=97, line=511 (Interpreted frame)
 - sun.security.pkcs11.P11Cipher.engineDoFinal(byte[], int, int, byte[], int) @bci=44, line=425 (Interpreted frame)
 - sun.security.pkcs11.P11Cipher.engineDoFinal(byte[], int, int) @bci=16, line=409 (Interpreted frame)
 - javax.crypto.Cipher.doFinal() @bci=15 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.CipherBox.dispose() @bci=11, line=482 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.SSLSocketImpl.closeInternal(boolean) @bci=485, line=1411 (Interpreted frame)
 - com.sun.net.ssl.internal.ssl.SSLSocketImpl.close() @bci=43, line=1301 (Interpreted frame)
 - com.tradingscreen.tunnel.api.TunnelConnection.closeSocket(java.net.Socket) @bci=5, line=149 (Interpreted frame)
 - com.tradingscreen.tunnel.api.TunnelConnection.doClose(boolean) @bci=199, line=192 (Interpreted frame)
 - com.tradingscreen.tunnel.api.TunnelConnection.close() @bci=2, line=159 (Interpreted frame)
 - com.tradingscreen.tunnel.api.TunnelPipe.close() @bci=16, line=129 (Interpreted frame)
 - com.tradingscreen.tunnel.api.TunnelPipe.run() @bci=192, line=100 (Compiled frame)