Re: "cache reference leak" and "problem in alloc set" warnings - Mailing list pgsql-hackers

From Tom Lane
Subject Re: "cache reference leak" and "problem in alloc set" warnings
Date
Msg-id 6178.1155825526@sss.pgh.pa.us
Whole thread Raw
In response to Re: "cache reference leak" and "problem in alloc set" warnings  (Volkan YAZICI <yazicivo@ttnet.net.tr>)
Responses Re: "cache reference leak" and "problem in alloc set" warnings
List pgsql-hackers
Volkan YAZICI <yazicivo@ttnet.net.tr> writes:
> I've still biten by a single "write past chunk" error while returning a
> record in PL/scheme:

>   WARNING:  problem in alloc set ExprContext: detected write past chunk
>   end in block 0x84a0598, chunk 0x84a0c84

The actual bug, almost certainly, is that you're miscomputing the space
needed for a variable-size palloc request.  But tracking that down will
be hard until you find out which chunk it is. 

Do you have a sequence that will make the problem happen consistently at
the same address?  If so, you can use a gdb watchpoint to find out where
the write-past-end is happening.  Or use a conditional breakpoint in
AllocSetAlloc to try to identify where the chunk is handed out.

Another possibility is to set a breakpoint where the warning is emitted
and take a look at the contents of the chunk to see if you can identify
it; that wouldn't require knowing the target chunk address in advance.

BTW, if I recall that code correctly, the "chunk address" in the message
is probably the address of the start of the overhead data for the chunk,
not the usable-space start address that is passed back by palloc.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pgsql-patches reply-to (was Re: [PATCHES] selecting
Next
From: Josh Berkus
Date:
Subject: Re: pgsql-patches reply-to (was Re: [PATCHES] selecting