From 7b6768b87e78777a97deb4f95de7d77f9e684415 Mon Sep 17 00:00:00 2001 From: Fantix King Date: Sun, 17 Mar 2019 17:51:10 -0500 Subject: [PATCH] bpo-34745: Fix asyncio sslproto memory issues (GH-12386) * Fix handshake timeout leak in asyncio/sslproto, refs MagicStack/uvloop#222 * Break circular ref _SSLPipe <-> SSLProtocol * bpo-34745: Fix asyncio ssl memory leak * Break circular ref SSLProtocol <-> UserProtocol * Add NEWS entry --- Lib/asyncio/sslproto.py | 4 ++++ .../next/Library/2019-03-17-16-43-29.bpo-34745.nOfm7_.rst | 1 + 2 files changed, 5 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2019-03-17-16-43-29.bpo-34745.nOfm7_.rst diff --git a/Lib/asyncio/sslproto.py b/Lib/asyncio/sslproto.py index 367f7d07a4184a..79e0745a75256a 100644 --- a/Lib/asyncio/sslproto.py +++ b/Lib/asyncio/sslproto.py @@ -478,7 +478,11 @@ def connection_lost(self, exc): self._loop.call_soon(self._app_protocol.connection_lost, exc) self._transport = None self._app_transport = None + if getattr(self, '_handshake_timeout_handle', None): + self._handshake_timeout_handle.cancel() self._wakeup_waiter(exc) + self._app_protocol = None + self._sslpipe = None def pause_writing(self): """Called when the low-level transport's buffer goes over diff --git a/Misc/NEWS.d/next/Library/2019-03-17-16-43-29.bpo-34745.nOfm7_.rst b/Misc/NEWS.d/next/Library/2019-03-17-16-43-29.bpo-34745.nOfm7_.rst new file mode 100644 index 00000000000000..d88f36a6d21736 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-03-17-16-43-29.bpo-34745.nOfm7_.rst @@ -0,0 +1 @@ +Fix :mod:`asyncio` ssl memory issues caused by circular references