Tomcat experiences high CPU in OpenSSLEngine.unwrap

Solution Verified - Updated

Environment

  • JBoss Web Server (JWS) 5.4.2 and earlier
    • Tomcat 9.0.36 and earlier

Issue

  • We see high CPU in threads that appear to be in an infinite loop in org.apache.tomcat.util.net.openssl.OpenSSLEngine.unwrap:
Thread 2844: (state = IN_JAVA)
 - java.nio.Bits.tryReserveMemory(long, int) @bci=29, line=712 (Compiled frame; information may be imprecise)
 - java.nio.Bits.reserveMemory(long, int) @bci=24, line=652 (Compiled frame)
 - java.nio.DirectByteBuffer.<init>(int) @bci=38, line=123 (Compiled frame)
 - java.nio.ByteBuffer.allocateDirect(int) @bci=5, line=311 (Compiled frame)
 - org.apache.tomcat.util.net.openssl.OpenSSLEngine.readPlaintextData(long, java.nio.ByteBuffer) @bci=84, line=331 (Compiled frame)
 - org.apache.tomcat.util.net.openssl.OpenSSLEngine.unwrap(java.nio.ByteBuffer, java.nio.ByteBuffer[], int, int) @bci=418, line=584 (Compiled frame)
 - javax.net.ssl.SSLEngine.unwrap(java.nio.ByteBuffer, java.nio.ByteBuffer) @bci=12, line=626 (Compiled frame)
 - org.apache.tomcat.util.net.SecureNioChannel.read(java.nio.ByteBuffer) @bci=77, line=617 (Compiled frame)
 - org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(boolean, java.nio.ByteBuffer) @bci=105, line=1229 (Compiled frame)
 - org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(boolean, java.nio.ByteBuffer) @bci=48, line=1141 (Compiled frame)
 - org.apache.coyote.http11.Http11InputBuffer.fill(boolean) @bci=147, line=780 (Compiled frame)
 - org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(boolean, int, int) @bci=49, line=356 (Compiled frame)
 - org.apache.coyote.http11.Http11Processor.service(org.apache.tomcat.util.net.SocketWrapperBase) @bci=108, line=260 (Compiled frame)
 - org.apache.coyote.AbstractProcessorLight.process(org.apache.tomcat.util.net.SocketWrapperBase, org.apache.tomcat.util.net.SocketEvent) @bci=170, line=65 (Compiled frame)
 - org.apache.coyote.AbstractProtocol$ConnectionHandler.process(org.apache.tomcat.util.net.SocketWrapperBase, org.apache.tomcat.util.net.SocketEvent) @bci=505, line=868 (Compiled frame)
 - org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun() @bci=214, line=1590 (Compiled frame)
 - org.apache.tomcat.util.net.SocketProcessorBase.run() @bci=21, line=49 (Compiled frame)
 - java.util.concurrent.ThreadPoolExecutor.runWorker(java.util.concurrent.ThreadPoolExecutor$Worker) @bci=95, line=1149 (Compiled frame)
 - java.util.concurrent.ThreadPoolExecutor$Worker.run() @bci=5, line=624 (Interpreted frame)
 - org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run() @bci=4, line=61 (Interpreted frame)
 - java.lang.Thread.run() @bci=11, line=748 (Interpreted frame)

Resolution

  • Upgrade to JWS 5.5.0+

Root Cause

Components
Category
Tags

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.