https://bz.apache.org/bugzilla/show_bug.cgi?id=63766

            Bug ID: 63766
           Summary: Resource leak: under certain conditions, request
                    objects related to WebSockets are not freed
           Product: Tomcat 8
           Version: 8.5.38
          Hardware: Macintosh
            Status: NEW
          Severity: major
          Priority: P2
         Component: WebSocket
          Assignee: dev@tomcat.apache.org
          Reporter: francis.vanae...@servicenow.com
  Target Milestone: ----

Created attachment 36794
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36794&action=edit
Code to reproduce the problem (see description)

Resource leak: under certain conditions, request objects related to WebSockets
are not freed

When Tomcat 8.5.38 is setting up a WebSocket (WS) connection with a client (or
has just set up the connection - not sure), and then receives a TCP RST on that
connection, it is possible that the associated objects are never freed. The
objects are of the classes below.

org.apache.tomcat.websocket.server.WsHandshakeRequest
org.apache.catalina.connector.Request
org.apache.coyote.Request
org.apache.coyote.RequestInfo
org.apache.catalina.connector.RequestFacade

We saw this happen in production, and we were able to reproduce this with test
code, running against our application, and against an out-of-the-box (OOB)
(embedded) Tomcat.

I have attached the stack traces of the two use cases (our application and OOB
Tomcat). Interestingly, the stack traces are different.

To reproduce the problem in a test environment, we have modified a TCP proxy to
send a RST packet to the server shortly after sending the WebSocket upgrade
HTTP request. When opening many WS connections, and having them automatically
interrupted with RST packets, after a while a number of objects seem to be
stuck in memory (see screenshot requests_objects.png). The objects stay in
memory even when the proxy and client are shut down.

Thank you for having a look at this. This failure mode does not happen often,
but when it happens, it eventually can bring the JVM down because of memory
pressure.

ATTACHMENT

The attachment contains:

tomcat-webserver: an OOB (embedded) Tomcat with a WS endpoint
websockets/tcp-proxy: a TCP proxy, modified to send RST packets - run ProxyMain
to start the proxy
websockets/websockets-client: a simple WS client, opening many connections -
run SadPath to reproduce the problem
requests_objects.png: a VisualVM screenshot showing stuck objects
web_socket_connection_reset.txt: two stack traces (the first when reproducing
the problem with our application, the second when reproducing the problem with
tomcat-webserver)

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to