classification
Title: test_ssl: reference cycle between ThreadedEchoServer and its ConnectionHandler
Type: resource usage Stage: resolved
Components: Tests Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords: patch

Created on 2017-09-01 14:58 by vstinner, last changed 2017-09-13 20:56 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3263 merged vstinner, 2017-09-01 14:59
PR 3538 merged python-dev, 2017-09-13 09:55
Messages (4)
msg301116 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-01 14:58
While testing bpo-31234 fix, I noticed that some test_ssl tests using ThreadedEchoServer create reference cycles with ConnectionHandler: ConnectionHandler fills ThreadedEchoServer.conn_errors with exceptions, but exceptions keep an alive traceback object which contains frame locals.

I tried to use traceback.clear_frames(), but this function is broken: see bpo-31321.

Attached PR works around the issue by storing errors are text rather than objects.

The PR prevents warnings about dangling threads.
msg301156 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-01 22:26
New changeset 868710158910fa38e285ce0e6d50026e1d0b2a8c by Victor Stinner in branch 'master':
bpo-31323: Fix reference leak in test_ssl (#3263)
https://github.com/python/cpython/commit/868710158910fa38e285ce0e6d50026e1d0b2a8c
msg302044 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-13 09:56
I don't think that Python 2.7 is affected since Exception has no __traceback__ attribute in Python 2.7.
msg302054 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-09-13 10:27
New changeset 1b00bddd5c4a5728b15eee5a27ed3f78a173ef64 by Victor Stinner (Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31323: Fix reference leak in test_ssl (GH-3263) (#3538)
https://github.com/python/cpython/commit/1b00bddd5c4a5728b15eee5a27ed3f78a173ef64
History
Date User Action Args
2017-09-13 20:56:41vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2017-09-13 10:27:36vstinnersetmessages: + msg302054
2017-09-13 09:56:33vstinnersetmessages: + msg302044
2017-09-13 09:55:36python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request3533
2017-09-01 22:26:19vstinnersetmessages: + msg301156
2017-09-01 14:59:51vstinnersetpull_requests: + pull_request3306
2017-09-01 14:58:24vstinnercreate