Re: memory bug debugging - Mailing list pgsql-hackers

From Tom Lane
Subject Re: memory bug debugging
Date
Msg-id 7881.1128435447@sss.pgh.pa.us
Whole thread Raw
In response to Re: memory bug debugging  (Martijn van Oosterhout <kleptog@svana.org>)
List pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> On Tue, Oct 04, 2005 at 01:11:41PM +0200, Markus Schiltknecht wrote:
>> I'm fiddling around with the backend and have created a memory bug. I
>> guess I'm overriding a palloced chunk, but can't figure out where.

> There are some defines (MEMORY_CONTEXT_CHECKING and
> CLOBBER_FREED_MEMORY) which can help find leaks.

Those are on by default if you built with --enable-cassert (which you
should surely always do when testing new backend code).

Best idea that comes to mind is:

(1) make sure you have a reproducible scenario in which the clobber
always happens at the same physical location.  (This shouldn't be too
hard if you start a fresh backend for each trial.)

(2) run it under gdb and set a hardware watchpoint at that location.

You'll get some false matches from touches in the aset.c code, but
hopefully not too many.  The first breakpoint outside aset.c is your
problem.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Ron Peacetree
Date:
Subject: Re: [PERFORM] A Better External Sort?
Next
From: "Jim C. Nasby"
Date:
Subject: Re: \d on database with a lot of tables is slow