double free or corruption (out) from psycopg2 connect using python 3.11.6

616 views Asked by At

I have a python application which uses postgres and works fine in a conda envirnment based on python 3.7.3. I am trying to update its conda environment to use a newer python version. I built the new environment ground up by repeatedly running the application to find missing packages and the installing them. Executing this script in the new environment:

import psycopg2 conn = psycopg2.connect("dbname='template1' user='dbuser' host='localhost' password='dbpass'")

Produces: double free or corruption (out) Aborted (core dumped) in the connect.

The postgres version is 10. I see this in /var/log/postgressql/postgresql-10-main.log evey time it's run: 2023-12-07 10:05:52.855 GMT [6618] [unknown]@[unknown] FATAL: no PostgreSQL user name specified in startup packet

psycopg2.version '2.9.9 (dt dec pq3 ext lo64)' python --version Python 3.11.6

Whether or not the username is correct, it shouldn't cause a core dump. Any help appreciated.

2

There are 2 answers

0
balazon On

I had the same issue, a workaround for me was downgrading openssl from 3.2.0 to 3.1.4:
conda install openssl=3.1.4
https://github.com/psycopg/psycopg2/issues/1658

Don't know why this is happening, maybe someone has more details.

Another workaround: install psycopg2-binary (or psycopg[binary] if you use psycopg version 3). That version has inbuilt ssl and libpq

0
titarch On

I faced this issue without conda as well, with simply my system openssl library being upgraded to 3.2.0.

An alternative workaround to downgrading openssl is to install psycopg2-binary instead of psycopg2.

Someone came up with a patch in postgresql: https://www.postgresql.org/message-id/[email protected], so you should expect the issue to be resolved fairly soon.