Skip to content

SSL issue when using psycopg in combination with tensorflow #1784

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

Closed
OlivierVerhaegen opened this issue May 22, 2025 · 1 comment
Closed

Comments

@OlivierVerhaegen
Copy link

OlivierVerhaegen commented May 22, 2025

Please complete the following information:

  • OS: Docker python 3.12-slim
  • Psycopg version: psycopg 3.2.9 (also binary and C), psycopg2 2.9.10 (also binary and C)
  • Python version: 3.12
  • PostgreSQL version: 16.3
  • pip version:

Describe the bug

After a long search and trial and error I found the following bug regarding the usage of psycopg in combination with Tensorflow.
Every time the application would have a segmentation error when starting up the SSL connection.

Image

Workaround was to import psycopg before tensorflow.
FYI: I tried all packages of psycopg (binary, c)

Image

Result afterwards:

Image

Hopefully this post helps other people to avoid this

@dvarrazzo
Copy link
Member

The issue has been reported upstream. Tensorflow uses BoringSSL, which is described as a fork of OpenSSL. Most likely this brings to a conflict in the global symbols.

I doubt we can do anything about it ourselves. Tensorflow should migrate to use OpenSSL instead but it's up to them to decide if and when.

While the import ordering seems to work for the author, it's not impossible that it will stop working at some time in the future. In order to prevent this to happen, my suggestion is to organise your software as a multi-process system, keeping separate the code importing Tensorflow from the code importing Psycopg, and to communicate between the two components using IPC.

Which is a pain, I understand. I had to do something similar in order to work around problems with... another Google library, gRPC. So is all I have to say is "meh".

Thank you very much for the report, I do hope it will be useful to others. Closing this here because we have no other action to take. If we can actively do something we can discuss about it in tensorflow/tensorflow#93969.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants