Re: [HACKERS] aggregation memory leak and fix - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] aggregation memory leak and fix
Date
Msg-id 199903201317.IAA21354@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] aggregation memory leak and fix  (Erik Riedel <riedel+@CMU.EDU>)
List pgsql-hackers
> 
> > No apologies necessary.  Glad to have someone digging into that area of
> > the code.  We will gladly apply your patches to 6.5.  However, I request
> > that you send context diffs(diff -c).  Normal diffs are just too
> > error-prone in application.   Send them, and I will apply them right
> > away.
> >  
> Context diffs attached.  This was due to my ignorance of diff.  When I
> made the other files, I though "hmm, these could be difficult to apply
> if the code has changed a bit, wouldn't it be good if they included a
> few lines before and after the fix".  Now I know "-c".

I have had to back out the nodeAgg.c part of the patch.  The rest looks
OK, partly because it is dealing with freeing expression context, and
partly because I don't understand it all.

The nodeAgg.c part of the patch is clearly trying to free memory
allocated as intermediate parts of the expression, and has to be solved
by a more general solution as I discussed.

If you look in backend/utils/adt/*.c, you will see lots of intermediate
memory allocated.  The allocacations as part of the *in/*out functions
are not a problem, because they are called only in other areas, and are
freed, but the other ones are probably not free'ed until statement
termination.  I may need to specifically put those pfree's in their own
context, and free them on tuple completion.

I am waiting to hear what others say about my ideas.  Feel free to keep
digging.


--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] min() and max() causing aborts
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] min() and max() causing aborts