home *** CD-ROM | disk | FTP | other *** search
Wrap
From NewsServ!fauern!ira.uka.de!sol.ctr.columbia.edu!spool.mu.edu!sdd.hp.com!elroy.jpl.nasa.gov!usc!ucsd!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage Wed Apr 10 08:51:32 MET DST 1991 Article: 1538 of gnu.utils.bug Path: NewsServ!fauern!ira.uka.de!sol.ctr.columbia.edu!spool.mu.edu!sdd.hp.com!elroy.jpl.nasa.gov!usc!ucsd!ucbvax!tut.cis.ohio-state.edu!unreplyable!garbage From: schulte@thp.uni-koeln.de Newsgroups: gnu.utils.bug Subject: gdbm-1.5 gdbm_reorganize() does not free memory Message-ID: <9104052012.AA17668@sun0.thp.Uni-Koeln.DE> Date: 5 Apr 91 20:12:47 GMT Article-I.D.: sun0.9104052012.AA17668 Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 13 Approved: bug-gnu-utils@prep.ai.mit.edu The gdbm_reorganize routine of gdbm-1.5 does not free content.dptr which can seriously increase the size of the program's memory-usage. A free(content.dptr) just before or after the free(key.dptr) should fix this. Martin -- Martin Schulte Institute for Theoretical Physics University of Cologne/Germany Internet: schulte@thp.uni-koeln.de From NewsServ!LRZnews!fauern!Sirius.dfn.de!darwin.sura.net!europa.asd.contel.com!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!uk.co.COMpnews.hem!phil Tue Jan 7 09:55:02 MEZ 1992 Article: 2294 of gnu.utils.bug Newsgroups: gnu.utils.bug Path: NewsServ!LRZnews!fauern!Sirius.dfn.de!darwin.sura.net!europa.asd.contel.com!uunet!wupost!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!uk.co.COMpnews.hem!phil From: phil@uk.co.COMpnews.hem (Phil Male) Subject: gdbm-1.5 Message-ID: <9564.9201051308@penfold.hem.compnews.co.uk> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Sun, 5 Jan 1992 14:08:51 GMT Approved: bug-gnu-utils@prep.ai.mit.edu Lines: 140 These are the patches to gdbm-1.5 gdbmreorg.c I had to apply to fix the memory leaks and to stop the file descriptor walking as a function of the reorganise (this is a feature that was causing problems for an application sitting above gdbm - seemed like a good idea to include these patches). These patches include the previous patch I posted to stop incorrect assignment of the cache_entry pointer. --- cut here *** gdbmreorg.c.old Thu Jan 2 03:37:18 1992 --- gdbmreorg.c Sun Jan 5 13:00:47 1992 *************** *** 74,79 **** --- 74,80 ---- gdbm_file_info *new_dbf; /* The new file. */ char *new_name; /* A temporary name. */ int len; /* Used in new_name construction. */ + int new_desc; /* Used to avoid walking file desc */ datum key, nextkey, data; /* For the sequential sweep. */ struct stat fileinfo; /* Information about the file. */ int index; /* Use in moving the bucket cache. */ *************** *** 131,138 **** gdbm_close (new_dbf); gdbm_errno = GDBM_REORGANIZE_FAILED; unlink (new_name); return -1; ! }; } else { --- 132,140 ---- gdbm_close (new_dbf); gdbm_errno = GDBM_REORGANIZE_FAILED; unlink (new_name); + free(new_name); return -1; ! } } else { *************** *** 140,145 **** --- 142,148 ---- gdbm_close (new_dbf); gdbm_errno = GDBM_REORGANIZE_FAILED; unlink (new_name); + free(new_name); return -1; } nextkey = gdbm_nextkey (dbf, key); *************** *** 153,164 **** { gdbm_errno = GDBM_REORGANIZE_FAILED; gdbm_close (new_dbf); return -1; } /* Fix up DBF to have the correct information for the new file. */ UNLOCK_FILE(dbf); ! close (dbf->desc); free (dbf->header); free (dbf->dir); for (index = 0; index < CACHE_SIZE; index++) --- 156,178 ---- { gdbm_errno = GDBM_REORGANIZE_FAILED; gdbm_close (new_dbf); + unlink (new_name); + free(new_name); return -1; } /* Fix up DBF to have the correct information for the new file. */ UNLOCK_FILE(dbf); ! /* close (dbf->desc); */ ! if ((new_desc = dup2(new_dbf->desc, dbf->desc)) < 0) ! { ! gdbm_close(new_dbf); ! gdbm_errno = GDBM_REORGANIZE_FAILED; ! unlink (new_name); ! free(new_name); ! return -1; ! } ! dbf->desc = new_desc; free (dbf->header); free (dbf->dir); for (index = 0; index < CACHE_SIZE; index++) *************** *** 169,180 **** free (dbf->bucket_cache[index].ca_data.dptr); } ! dbf->desc = new_dbf->desc; dbf->header = new_dbf->header; dbf->dir = new_dbf->dir; dbf->bucket = new_dbf->bucket; dbf->bucket_dir = new_dbf->bucket_dir; ! dbf->cache_entry = new_dbf->cache_entry; dbf->last_read = new_dbf->last_read; for (index = 0; index < CACHE_SIZE; index++) dbf->bucket_cache[index] = new_dbf->bucket_cache[index]; --- 183,195 ---- free (dbf->bucket_cache[index].ca_data.dptr); } ! /* dbf->desc = new_dbf->desc; */ dbf->header = new_dbf->header; dbf->dir = new_dbf->dir; dbf->bucket = new_dbf->bucket; dbf->bucket_dir = new_dbf->bucket_dir; ! /* dbf->cache_entry = new_dbf->cache_entry; */ ! dbf->cache_entry = &dbf->bucket_cache[new_dbf->last_read]; dbf->last_read = new_dbf->last_read; for (index = 0; index < CACHE_SIZE; index++) dbf->bucket_cache[index] = new_dbf->bucket_cache[index]; *************** *** 187,192 **** --- 202,209 ---- /* Make sure the new database is all on disk. */ fsync (dbf->desc); + + free(new_name); return 0; } --- cut here phil ------------------------------------------------------------------------------ ___/ / /_/) / Phil Male, Information Systems Engineering Group / /_ '/ Computer Newspaper Services, The Bishops Manor, Howden, DN14 7BL / / /// ------------------------------------------------------------------------------ Confidence is the feeling you have before you understand the situation.