BUG #6133: -lpq frees unallocated memory on exit

From: "Kurt Mielke" <kurt(at)it-pilots(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #6133: -lpq frees unallocated memory on exit
Date: 2011-07-27 20:15:30
Message-ID: 201107272015.p6RKFUkV094593@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

Bug reference: 6133
Logged by: Kurt Mielke
Email address: kurt(at)it-pilots(dot)com
PostgreSQL version: 8.4.8 + 9.0.4
Operating system: Centos X86_64 5.5 & 6.0
Description: -lpq frees unallocated memory on exit
Details:

x.c: is a very simple c-program:

main() { }

When compiled with

gcc -o x -lpq x.c

valgrind ./x

says "invalid free ... Address 0x4029508 is not stack'd, malloc'd or
(recently) free'd"

gcc -o x x.c

does not have this problem

I have tried linking with centos distribution developer versions and tried
making it from 8.4.2 8.4.8 9.0.4 tar balls, using configure with no options
The problem is the same - I found a posting from 2002 which I think is the
same problem, but I found no follow-ups.

I looked at make output to identify other libraries, which might be
responsible - but:

gcc -o x -lcrypt -ldl -lm -lpgport -lpgtypes -lpthread -lreadline -lz x.c

is OK, while linking with either -lpq or -lecpg will give you the valgrind
error.

On the two machines I tried it on I have:
gcc.x86_64 4.4.4-13.el6 / glibc.i686 2.12-1.7.el6_0.5
gcc.x86_64 4.1.2-50.el5 / glibc.i686 2.5-58.el5_6.4

And "Yes!" - the problem is also present if I do some real pg-lib, like
running testlibpq3.c - again there is one free too many.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Robert Haas 2011-07-27 20:28:25 Re: BUG #5953: pgadmin sql-query text pad doesn't work
Previous Message Robert Haas 2011-07-27 19:20:56 Re: Ambiguos OPERATOR items in pg_restore manifest file