mirror of
https://github.com/python/cpython.git
synced 2025-09-30 12:21:51 +00:00
[3.6] bpo-31323: Fix reference leak in test_ssl (GH-3263) (#3538)
Store exceptions as string rather than object to prevent reference
cycles which cause leaking dangling threads.
(cherry picked from commit 8687101589
)
This commit is contained in:
parent
547f2a97ea
commit
1b00bddd5c
1 changed files with 6 additions and 2 deletions
|
@ -1867,7 +1867,11 @@ if _have_threads:
|
||||||
# XXX Various errors can have happened here, for example
|
# XXX Various errors can have happened here, for example
|
||||||
# a mismatching protocol version, an invalid certificate,
|
# a mismatching protocol version, an invalid certificate,
|
||||||
# or a low-level bug. This should be made more discriminating.
|
# or a low-level bug. This should be made more discriminating.
|
||||||
self.server.conn_errors.append(e)
|
#
|
||||||
|
# bpo-31323: Store the exception as string to prevent
|
||||||
|
# a reference leak: server -> conn_errors -> exception
|
||||||
|
# -> traceback -> self (ConnectionHandler) -> server
|
||||||
|
self.server.conn_errors.append(str(e))
|
||||||
if self.server.chatty:
|
if self.server.chatty:
|
||||||
handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n")
|
handle_error("\n server: bad connection attempt from " + repr(self.addr) + ":\n")
|
||||||
self.running = False
|
self.running = False
|
||||||
|
@ -3081,7 +3085,7 @@ if _have_threads:
|
||||||
with context.wrap_socket(socket.socket()) as s:
|
with context.wrap_socket(socket.socket()) as s:
|
||||||
with self.assertRaises(OSError):
|
with self.assertRaises(OSError):
|
||||||
s.connect((HOST, server.port))
|
s.connect((HOST, server.port))
|
||||||
self.assertIn("no shared cipher", str(server.conn_errors[0]))
|
self.assertIn("no shared cipher", server.conn_errors[0])
|
||||||
|
|
||||||
def test_version_basic(self):
|
def test_version_basic(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue