Skip to content

Issues calling ssl.create_default_context() from within threads while using Fedora. #207

Open
@xlevus

Description

Calling ssl.create_default_context() in version 20240107 and 20231002 from within a threading.Thread() will error with pythonX.Y: unknown error (_ssl.c:ZZZZ)

Observances:

  • This only seems to occur on Fedora systems (Fedora 37 and 39 tested)
  • The issue was introduced in version 20231002 and exists in 20240107
  • The issue can be entirely avoided by just calling ssl.create_default_context() in the primary thread (but, see below WRT openSSL documentation)
  • I cannot reproduce the issue with any of the python versions distributed by Fedora.

The issue was found from the Pants project (which runs Pex within a PBS runtime) pantsbuild/pants#20467

I've created a repository with a Dockerfile and a script that can reproduce the issue here: https://github.com/xlevus/pants-issue-20467/tree/main (see simple/repro.sh)

I have no idea where the issue actually sits. The OpenSSL documentation on SSL_CTX is somewhat ambiguous too:

An SSL_CTX object should not be changed after it is used to create any SSL objects or from multiple threads concurrently, since the implementation does not provide serialization of access for these cases.

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingupstreamAn upstream dependency is involved

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions