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

2

6

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.

Monticule answered 7/12, 2023 at 10:28 Comment(4)
What version of psycopg2 is that? May it be that it dropped support for postgresql-10? Because postgres is a few major versions behind.Pyrostat
1) psycopg2 uses libpq which is backwards compatible to Postgres 7.4, so it will handle Postgres 10. 2) How did you install psycopg2? 3) Did you reinstall/rebuild it when you changed the Cond env?Dreda
That doesn't depend on the username: I'm also getting "FATAL: no PostgreSQL user name specified in startup packet" in my PG logs however using a separate installation of python with the appropriate libraries, out of conda, does not show this issue though the exact same code runs with the same credentials.Thermogenesis
Hi. I'm still not clear what the issue was that caused my problem, but it has resolved. I did: conda update -n base -c conda-forge conda And the situation improved. Conda then gave me a more useful error message - forget the details sorry - and I was able to resolve problems. Thanks to Adrian, Julaine and Ten for responding to this. Ian.Monticule
K
8

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

Kedgeree answered 18/12, 2023 at 10:4 Comment(0)
L
0

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.

Leningrad answered 19/12, 2023 at 13:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.