home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / rcs / sources / gdbm.bug < prev    next >
Internet Message Format  |  1992-01-18  |  6KB

  1. 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
  2. Article: 1538 of gnu.utils.bug
  3. 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
  4. From: schulte@thp.uni-koeln.de
  5. Newsgroups: gnu.utils.bug
  6. Subject: gdbm-1.5 gdbm_reorganize() does not free memory
  7. Message-ID: <9104052012.AA17668@sun0.thp.Uni-Koeln.DE>
  8. Date: 5 Apr 91 20:12:47 GMT
  9. Article-I.D.: sun0.9104052012.AA17668
  10. Sender: daemon@tut.cis.ohio-state.edu
  11. Distribution: gnu
  12. Organization: GNUs Not Usenet
  13. Lines: 13
  14. Approved: bug-gnu-utils@prep.ai.mit.edu
  15.  
  16. The gdbm_reorganize routine of gdbm-1.5 does not free content.dptr which
  17. can seriously increase the size of the program's memory-usage.
  18.  
  19. A free(content.dptr) just before or after the free(key.dptr) should fix
  20. this.
  21.  
  22. Martin
  23. --
  24. Martin Schulte
  25. Institute for Theoretical Physics
  26. University of Cologne/Germany
  27.  
  28. Internet: schulte@thp.uni-koeln.de
  29.  
  30.  
  31. 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
  32. Article: 2294 of gnu.utils.bug
  33. Newsgroups: gnu.utils.bug
  34. 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
  35. From: phil@uk.co.COMpnews.hem (Phil Male)
  36. Subject: gdbm-1.5
  37. Message-ID: <9564.9201051308@penfold.hem.compnews.co.uk>
  38. Sender: gnulists@ai.mit.edu
  39. Organization: GNUs Not Usenet
  40. Distribution: gnu
  41. Date: Sun, 5 Jan 1992 14:08:51 GMT
  42. Approved: bug-gnu-utils@prep.ai.mit.edu
  43. Lines: 140
  44.  
  45. These are the patches to gdbm-1.5 gdbmreorg.c I had to apply to fix the memory
  46. leaks and to stop the file descriptor walking as a function of the reorganise
  47. (this is a feature that was causing problems for an application sitting above
  48. gdbm - seemed like a good idea to include these patches).
  49. These patches include the previous patch I posted to stop incorrect assignment
  50. of the cache_entry pointer.
  51.  
  52. --- cut here
  53. *** gdbmreorg.c.old    Thu Jan  2 03:37:18 1992
  54. --- gdbmreorg.c    Sun Jan  5 13:00:47 1992
  55. ***************
  56. *** 74,79 ****
  57. --- 74,80 ----
  58.     gdbm_file_info *new_dbf;        /* The new file. */
  59.     char *new_name;            /* A temporary name. */
  60.     int  len;                /* Used in new_name construction. */
  61. +   int new_desc;                /* Used to avoid walking file desc */
  62.     datum key, nextkey, data;        /* For the sequential sweep. */
  63.     struct stat fileinfo;            /* Information about the file. */
  64.     int  index;                /* Use in moving the bucket cache. */
  65. ***************
  66. *** 131,138 ****
  67.             gdbm_close (new_dbf);
  68.             gdbm_errno = GDBM_REORGANIZE_FAILED;
  69.             unlink (new_name);
  70.             return -1;
  71. !         };
  72.        }
  73.         else
  74.        {
  75. --- 132,140 ----
  76.             gdbm_close (new_dbf);
  77.             gdbm_errno = GDBM_REORGANIZE_FAILED;
  78.             unlink (new_name);
  79. +           free(new_name);
  80.             return -1;
  81. !         }
  82.        }
  83.         else
  84.        {
  85. ***************
  86. *** 140,145 ****
  87. --- 142,148 ----
  88.         gdbm_close (new_dbf);
  89.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  90.         unlink (new_name);
  91. +       free(new_name);
  92.         return -1;
  93.        }
  94.         nextkey = gdbm_nextkey (dbf, key);
  95. ***************
  96. *** 153,164 ****
  97.       {
  98.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  99.         gdbm_close (new_dbf);
  100.         return -1;
  101.       }
  102.   
  103.     /* Fix up DBF to have the correct information for the new file. */
  104.     UNLOCK_FILE(dbf);
  105. !   close (dbf->desc);
  106.     free (dbf->header);
  107.     free (dbf->dir);
  108.     for (index = 0; index < CACHE_SIZE; index++)
  109. --- 156,178 ----
  110.       {
  111.         gdbm_errno = GDBM_REORGANIZE_FAILED;
  112.         gdbm_close (new_dbf);
  113. +       unlink (new_name);
  114. +       free(new_name);
  115.         return -1;
  116.       }
  117.   
  118.     /* Fix up DBF to have the correct information for the new file. */
  119.     UNLOCK_FILE(dbf);
  120. !   /* close (dbf->desc); */
  121. !   if ((new_desc = dup2(new_dbf->desc, dbf->desc)) < 0)
  122. !     {
  123. !       gdbm_close(new_dbf);
  124. !       gdbm_errno = GDBM_REORGANIZE_FAILED;
  125. !       unlink (new_name);
  126. !       free(new_name);
  127. !       return -1;
  128. !     }
  129. !   dbf->desc = new_desc;
  130.     free (dbf->header);
  131.     free (dbf->dir);
  132.     for (index = 0; index < CACHE_SIZE; index++)
  133. ***************
  134. *** 169,180 ****
  135.       free (dbf->bucket_cache[index].ca_data.dptr);
  136.       }
  137.   
  138. !   dbf->desc           = new_dbf->desc;
  139.     dbf->header         = new_dbf->header;
  140.     dbf->dir            = new_dbf->dir;
  141.     dbf->bucket         = new_dbf->bucket;
  142.     dbf->bucket_dir     = new_dbf->bucket_dir;
  143. !   dbf->cache_entry    = new_dbf->cache_entry;
  144.     dbf->last_read      = new_dbf->last_read;
  145.     for (index = 0; index < CACHE_SIZE; index++)
  146.       dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
  147. --- 183,195 ----
  148.       free (dbf->bucket_cache[index].ca_data.dptr);
  149.       }
  150.   
  151. !   /* dbf->desc           = new_dbf->desc; */
  152.     dbf->header         = new_dbf->header;
  153.     dbf->dir            = new_dbf->dir;
  154.     dbf->bucket         = new_dbf->bucket;
  155.     dbf->bucket_dir     = new_dbf->bucket_dir;
  156. !   /* dbf->cache_entry    = new_dbf->cache_entry; */
  157. !   dbf->cache_entry    = &dbf->bucket_cache[new_dbf->last_read];
  158.     dbf->last_read      = new_dbf->last_read;
  159.     for (index = 0; index < CACHE_SIZE; index++)
  160.       dbf->bucket_cache[index] = new_dbf->bucket_cache[index];
  161. ***************
  162. *** 187,192 ****
  163. --- 202,209 ----
  164.   
  165.     /* Make sure the new database is all on disk. */
  166.     fsync (dbf->desc);
  167. +   free(new_name);
  168.   
  169.     return 0;
  170.   }
  171. --- cut here
  172.  
  173. phil 
  174.  
  175.  ------------------------------------------------------------------------------
  176.    ___/   /
  177.    /_/)  /         Phil Male, Information Systems Engineering Group
  178.   / /_ '/  Computer Newspaper Services, The Bishops Manor, Howden, DN14 7BL
  179.  / / ///
  180.  ------------------------------------------------------------------------------
  181.  
  182. Confidence is the feeling you have before you understand the situation.
  183.  
  184.  
  185.  
  186.