Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] too many pfree in large object

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: t-ishii(at)sra(dot)co(dot)jp
Cc: hackers(at)postgreSQL(dot)org, t-ishii(at)sra(dot)co(dot)jp
Subject: Re: [HACKERS] too many pfree in large object
Date: 1998-10-06 03:58:05
Message-ID: 199810060358.XAA27363@candle.pha.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
> Hi, there's a small bug in inv_fetchup().
> In the following do-while loop, res is freed at the very
> end of the loop. However, after getting out of the loop,
> it gets freed again. Not good. Possible fix would be
> changing the pfree(res) in the loop to:
> 
>   if (tuple == (HeapTuple)NULL) pfree(res);
> 
> ------------------- inv_api.c ----------------------
> 			tuple = heap_fetch(obj_desc->heap_r, SnapshotNow,
> 							   &res->heap_iptr, buffer);
> 			pfree(res);
> 		} while (tuple == (HeapTuple) NULL);
> 
> 		/* remember this tid -- we may need it for later reads/writes */
> 		ItemPointerCopy(&(res->heap_iptr), &(obj_desc->htid));
> 		pfree(res);
> 	}

Thanks.  Fixed.  I changed the line to read:

        ItemPointerCopy(&tuple->t_ctid, &obj_desc->htid);

This way, I am getting it from the heap, not from the index tuple, and
removed the duplicate pfree().

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


In response to

pgsql-hackers by date

Next:From: Bruce MomjianDate: 1998-10-06 04:06:45
Subject: Re: [HACKERS] select * from ..;vacuum crashes
Previous:From: Bruce MomjianDate: 1998-10-06 03:10:53
Subject: Re: [HACKERS] Dumping of views -- done!

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group