Skip to content

getting ssl.SSLSocket.session brings to memory leak #116810

Description

@vetonyx

Bug report

Bug description:

Ubuntu 22.04
python 3.12, python3.11

import ssl
import socket
import time
host = '192.168.16.66' # some server we can connect with https as example
port = 443

session = None
context = ssl._create_unverified_context(protocol=ssl.PROTOCOL_TLSv1_2)
with socket.create_connection((host, port)) as sock:
    with context.wrap_socket(sock, server_hostname=host, session = session) as ssock:
        for i in range(300000):
            session = ssock.session

print('Sleeping')
time.sleep(200)

Here is part of script that is used for "ssl reuse" session during connection to server
Running this script brings to memory leak (process memory increased from 322Mb to 2.5Gb).
Memory is not freed on "time.sleep" instruction
Not reproduced on python 3.8

CPython versions tested on:

3.11, 3.12

Operating systems tested on:

Linux

Linked PRs

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

topic-SSLtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions