Skip to content

TLSSocket appears to be leaking, possibly on Connection Reset with HTTP2 #42710

@clshortfuse

Description

@clshortfuse

Version

v16.14.2

Platform

Linux host.ec2.internal 4.14.243-185.433.amzn2.x86_64 #1 SMP Mon Aug 9 05:55:52 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Subsystem

http2 streams http tls

What steps will reproduce the bug?

Load up an HTTP2 server with SSL certificate. Perform requests, but don't complete them.

eg:

  • disconnect before stream can be is read
  • send bad SSL data
  • disconnect between response can be written

After a while, ServerHttp2Session, nghttp2_memory, and Http2Session vastly outnumber number of Http2ServerRequest or Http2ServerResponse references.

How often does it reproduce? Is there a required condition?

I believe it's from connection reset.

What is the expected behavior?

Objects should be cleared.

What do you see instead?

I have numerous memory snapshots and about 15 production servers exhibiting this issue. I can love dump a heapshot as needed. One shows the issue clearly with 102 ServerHttp2Session objects, but only 18 Http2ServerRequest objects.

TLSSocket appears to clearly show that the references are internal. 21 out of 122 have a distance to window. The rest appear to leak.

image

image


After rewriting code to eliminate all stream/session listeners to avoid leaking and only using getPipeline(), I have a recent example of 40 sessions, 24 streams, and 21 req/res. The leaking ServerHttp2Session look like this:

image

An active req/res (with middleware) looks like this:

image

Additional information

I have have more snapshots and can pull them. The HttpResponse and HttpRequest objects are custom middleware. The other 16 Http2ServerRequest objects are mostly socket.io objects, but they don't appear to leak. If you need the actual files, I'm on Slack and can share there (since snapshots have private information).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions