Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 7F0FAB5DC08 for ; Wed, 27 Jul 2011 17:15:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 50107-09 for ; Wed, 27 Jul 2011 20:15:31 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by mail.postgresql.org (Postfix) with ESMTP id C3CAAB5DC04 for ; Wed, 27 Jul 2011 17:15:30 -0300 (ADT) Received: from wwwmaster.postgresql.org (wwwmaster.postgresql.org [217.196.146.204]) by wwwmaster.postgresql.org (8.14.3/8.14.3) with ESMTP id p6RKFUE3094594 for ; Wed, 27 Jul 2011 20:15:30 GMT (envelope-from www@wwwmaster.postgresql.org) Received: (from www@localhost) by wwwmaster.postgresql.org (8.14.3/8.14.3/Submit) id p6RKFUkV094593; Wed, 27 Jul 2011 20:15:30 GMT (envelope-from www) Date: Wed, 27 Jul 2011 20:15:30 GMT Message-Id: <201107272015.p6RKFUkV094593@wwwmaster.postgresql.org> To: pgsql-bugs@postgresql.org Subject: BUG #6133: -lpq frees unallocated memory on exit From: "Kurt Mielke" Content-Type: text/plain; charset=utf-8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 201107/196 X-Sequence-Number: 30808 The following bug has been logged online: Bug reference: 6133 Logged by: Kurt Mielke Email address: kurt@it-pilots.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.