-
Notifications
You must be signed in to change notification settings - Fork 567
Fixes #220 sslproto memory issue #222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
9d93438
to
57c62af
Compare
57c62af
to
e6406b4
Compare
OK if tests pass I think this PR is good enough now, please kindly review. |
Looks like it's red :( |
e6406b4
to
e2bba47
Compare
Oh I'm stupid, has been investigating why Okay found the same (part of) bug in asyncio, skipping the test for now, I'll create another PR to fix in asyncio. (So the bug is, the handshake timeout handle is never cancelled if the handshake was terminated early - an additional timeout for example. In this case, all objects in the reference chain including SSLProtocol, transport, SSLContext will remain in memory until the handle actually times out, thus it is some kind of a memory leak.) |
4197eb4
to
2f9ea1a
Compare
There were two issues: 1) at `connection_lost()` the timeout handle was never cancelled because getting a cdef property on a cdef class with `getattr` always return `None`, and 2) for now cancelling a uvloop timeout handle only clears references to call arguments but not the callback object itself, therefore the closure is now a part of the arguments to avoid SSLProtocol object stays in memory until the cancelled timeout handle actually get deallocated.
2f9ea1a
to
c3e8ce6
Compare
* Fix handshake timeout leak in asyncio/sslproto Refs MagicStack/uvloopGH-222 * Break circular ref _SSLPipe <-> SSLProtocol * bpo-34745: Fix asyncio ssl memory leak * Break circular ref SSLProtocol <-> UserProtocol * Add NEWS entry (cherry picked from commit f683f46) Co-authored-by: Fantix King <fantix.king@gmail.com>
* 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
* Fix handshake timeout leak in asyncio/sslproto Refs MagicStack/uvloopGH-222 * Break circular ref _SSLPipe <-> SSLProtocol * bpo-34745: Fix asyncio ssl memory leak * Break circular ref SSLProtocol <-> UserProtocol * Add NEWS entry (cherry picked from commit f683f46) Co-authored-by: Fantix King <fantix.king@gmail.com>
* 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
I think this could at least fix the issue that is reproducible with the given script in #220. In the meantime, I'm still looking for more corner cases that may lead to issues.
Tasks below shall be addressed in a new PR:
SSLTransport
that is never closed by orphaned AppProtocol (shared with asyncio?)