libpq3 + ssl memory leak

From: Olaf Hartmann <hao(at)telemedsys(dot)de>
To: pgsql-bugs(at)postgresql(dot)org
Subject: libpq3 + ssl memory leak
Date: 2003-12-03 16:49:41
Message-ID: 3FCE1425.3030400@telemedsys.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : Olaf Hartmann
Your email address : hao(at)telemedsys(dot)de

System Configuration
---------------------
Architecture (example: Intel Pentium) : i386

Operating System (example: Linux 2.0.26 ELF) : linux-2.4.21

PostgreSQL version (example: PostgreSQL-7.3.4): PostgreSQL-7.4

Compiler used (example: gcc 2.95.2) : gcc 3.3.2

Please enter a FULL description of your problem:
------------------------------------------------

We expirience a memory leak with every connection when using an SSL
encrypted TCP connection to connect a postgres database.
A simple code example is included in this mail. It simply opens and
closes a database connection. (You also need a postgresql server set up
for ssl.)

'valgrind' detects the main memory leak (which gets bigger with every
connection) to be in libcrypto.so.0.9.7. But you can also verify the
increased memory consumption using 'ps axl', if you add a 'sleep(..);'
at the end of the program.

Please describe a way to repeat the problem. Please try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

/*
* begin leak.c
*/

#include <stdio.h>
#include <postgresql/libpq-fe.h>

int main()
{
int i;
PGconn *conn;

for (i = 0; i < 10; i ++)
{
conn = PQconnectdb("host=... dbname=template1 ... requiressl=1");
if (PQstatus(conn) == CONNECTION_BAD)
{
fprintf(stderr, "Error: %s", PQerrorMessage(conn));
PQfinish(conn);
exit(1);
}
PQfinish(conn);
}
return 0;
}

/*
* end leak.c
*/

$ gcc leak.c -lpq -o leak

$ valgrind --leak-check=yes --error-limit=no ./leak

If you know how this problem might be fixed, list the solution below:
---------------------------------------------------------------------

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2003-12-03 16:52:55 Re: Seg Fault when using modules linked both to libpq and libodbcpsql.
Previous Message Joseph Tate 2003-12-03 16:44:33 Bug in pg_restore or in postmaster itself?