Re: BUG #2246: Bad malloc interactions: ecpg, openssl

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Klosterman <andrew5(at)ece(dot)cmu(dot)edu>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #2246: Bad malloc interactions: ecpg, openssl
Date: 2006-02-13 20:16:05
Message-ID: 4050.1139861765@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-patches

Andrew Klosterman <andrew5(at)ece(dot)cmu(dot)edu> writes:
> I threw in a pthread mutex around the code making the database connections
> for each of my threads. The problem is still there ("corrupted
> double-linked list").

> Even tuning things down and instructing my code to only run a single
> pthread manifests the problem over an SSL connection.

Hmm. Based on that, the problem is starting to smell more like a
garden-variety memory clobber, for instance malloc'ing a chunk smaller
than the data that's later stuffed into it. It might be worth running
the program under something like ElectricFence, which will catch the
offender on-the-spot rather than only later when corruption of malloc's
private data structures is detected.

Looking back at your original message, I wonder if it could be the
combination of ecpg and SSL that triggers it? I'd have thought that
libpq/SSL alone would be pretty well wrung out, but ecpg is not so
widely used.

BTW, you did say this was i386 right? If it were a 64-bit architecture,
I'd be about ready to bet money on the wrong-malloc-size-calculation
theory.

> Tracking down exactly what's tickling the problem in this case could be
> tricky...

Yeah :-(. If you aren't able to narrow it further by yourself, please
try to put together a self-contained test case.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Klosterman 2006-02-13 21:01:32 Re: BUG #2246: Bad malloc interactions: ecpg, openssl
Previous Message Andrew Klosterman 2006-02-13 19:35:49 Re: BUG #2246: Bad malloc interactions: ecpg, openssl

Browse pgsql-patches by date

  From Date Subject
Next Message Andrew Klosterman 2006-02-13 21:01:32 Re: BUG #2246: Bad malloc interactions: ecpg, openssl
Previous Message Bruce Momjian 2006-02-13 19:59:43 Re: Free WAL caches on switching segments