home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / reviewed / volume02 / malloclb / part00 < prev    next >
Encoding:
Internet Message Format  |  1992-03-31  |  7.1 KB

  1. From: Conor P. Cahill <cpcahil%virtech@uunet.UU.NET>
  2. Subject: v02i001: malloclib - Malloc Debugging Library, Part00/05
  3. Newsgroups: comp.sources.reviewed
  4. Approved: csr@calvin.dgbt.doc.ca
  5.  
  6. Submitted-by: Conor P. Cahill <cpcahil%virtech@uunet.UU.NET>
  7. Posting-number: Volume 2, Issue 1
  8. Archive-name: malloclib/part00
  9.  
  10. Environment: UNIX
  11.  
  12. Tested Environments:
  13.     VAX, BSD 4.3, 
  14.     VAXstation 3100, ULTRIX-32 v3.1 R11 
  15.     IBM RT/PC, AOS 4.3, 
  16.     DECstation 3100, Ultrix 4.2, 
  17.     IBM RS/6000, AIX 
  18.     Sun4, SunOS 4.1
  19.     Sun SPARCsystem 400, SunOS Release 4.1.1  
  20.     HP 9000 Series 300, HP-UX 8.0
  21.     HP9000/827, HPUX 8.0.2 
  22.     Solbourne Series5e/900, OS/MP 4.1A.1 
  23.     ISC 386 UNIX box, ISC 2.2.1 
  24.  
  25. Dates:
  26.     Submission Received: Nov 25 1991
  27.     Revised Version Received: Dec 3 1991
  28.     Reviews Returned: Dec 30 1991
  29.     Revised Version Received: Jan 3 1991
  30.     Reviews Returned: Jan 25 1992
  31.     Revised Version Received: Jan 28 1992
  32.     Accepted: Mar 26 1992
  33.     
  34.     
  35. Author's Summary:
  36. -----------------
  37.  
  38. Malloclib is a replacement library for the standard malloc functions
  39. which provides a full range of debugging features including:
  40.  
  41.         * tracking of allocations (to assist in finding memory leaks)
  42.         * detection of out-of-bounds acess to malloc data
  43.         * assistance in finding the cause of malloc chain corruption
  44.  
  45. An earlier version was posted to comp.sources.unix in May of 1990.  The
  46. vast amount of changes in this version make it necessary to re-release
  47. the entire library. The new enhancments/bug fixes include:
  48.  
  49.         * tracking of where the item was allocated (to ease debugging)
  50.         * enhanced malloc chain dump information
  51.         * enhanced error reporting 
  52.         * new/much better manual page
  53.         * leak detection enhancements
  54.         * port to ANSI-C (works for both K&R & ANSI and hybrids)
  55.         * and many bug-fixes (thanks to all those that submitted reports)
  56.  
  57.  
  58. Reviewers' Comments:
  59. --------------------
  60.  
  61. [Building this package requires setting 3 parameters:  DATATYPE,
  62. SIZETYPE, and VOIDTYPE.  Instructions for this are included in the
  63. README file, but we have found that some trial-and-error may be
  64. necessary before the package builds without errors.  Also, given the
  65. non-standard nature of include files across different environments,
  66. builders may have to make some small changes during the installation.
  67. -- Moderator]
  68.  
  69. ------------------------------------------------------------------------
  70.  
  71.   Malloclib is a useful library that I am sure I will use in the
  72. future when debugging memory problems in programs on which I am
  73. working.  This new version is even more valuable than previous
  74. versions, and I am going to install it in a publicly accessible area
  75. on our systems as soon as the final version comes out in
  76. comp.sources.reviewed.
  77.  
  78. - on the RT/PC running AOS 4.3, don't define bcopy() because of
  79. conflicts with the C library.
  80. - programs that include <string.h> on the RS/6000 are going to get the
  81. built-in __strcpy and __strmp routines even if they link against the
  82. dbmalloc library, because of the #define's in <string.h>.  [See similar
  83. comments about building under HP-UX below. -- Moderator.]
  84.  
  85. ------------------------------------------------------------------------
  86.  
  87. Unfortunately the compiler on ULTRIX (cc) did not like 
  88.     typedef void VOIDTYPE;
  89. which was easily found as an example.  I used 
  90.     #define VOIDTYPE void 
  91. instead. This seemed to work fine.
  92. ...
  93. The 'basic' functionality is fine: one can quite easily link a
  94. debugged version of a faulty program and find out what is wrong. This
  95. is a Good Thing.
  96.  
  97. There is a nice set of features for controlling the output and
  98. behaviour of the package during memory operations and in error
  99. situations. The features look all like useful ones; all of them were
  100. not tested. The package appears to be a growing one in the sense that
  101. one can use it really effectively, if the easy methods are not enough.
  102. It is possible to just link the thing and enjoy or to read the manual
  103. thoroughly and use 'advanced' features. This looks like well designed
  104. software. 
  105. ...
  106. The package offers a very valuable set of tools for debugging memory
  107. allocations. The features are both relevant and well organized. One
  108. can use the package as a place in replacement of 'malloc' and 'free'
  109. or use the more advanced features of the package.
  110.  
  111. The package seems to run just fine. No large tests were run (I am not
  112. alone on these machines and e.g. malloccing all the memory I can get
  113. could generate dissatisfaction among other users). All the tested
  114. cases (none of which were real, unfortunately) performed just fine.
  115.  
  116. I would recommend this piece of code to anyone who is suffering from
  117. the pains of memory management under unix and c. I shall  use
  118. this package from now on, whenever I find myself in trouble.
  119.  
  120. ------------------------------------------------------------------------
  121.  
  122. The problem I had building this software was that for my system
  123. (HP-UX), SIZETYPE wanted to be size_t, and the argument to sbrk in
  124. mallocint.h:
  125.  
  126. DATATYPE        * sbrk __stdcargs((SIZETYPE));
  127.  
  128. needed to be:
  129. DATATYPE        * sbrk __stdcargs((int));
  130.  
  131. This seems like a very useful package for tracing down memory leaks
  132. and cases where one tries to memcpy to a pointer or overuns a malloc'd
  133. region.  The package appears to provide a useful service, with only a
  134. moderate slowdown.
  135.  
  136. ------------------------------------------------------------------------
  137.  
  138. Malloclib is a fine package for assisting you in finding problems with
  139. dynamic memory allocation.  It works by replacing the malloc routines,
  140. along with many of the other functions that often work with dynamically
  141. allocated memory.  Each call of these functions checks to make sure
  142. that they are going to use the memory properly.  It is a very good
  143. package for finding memory allocation problems during program
  144. development.  It can't do a full "memory leak" check, but it does have
  145. provisions for auditing allocated memory, identifying bad references,
  146. checking memory overrun and so-on.
  147.  
  148. The only problem I had with it was compiling it on HPUX which has
  149. relatively strange ideas of what the system include files look like -
  150. malloclib provides declarations for the string(3) and memory(3)
  151. routines it replaces, some which are bound to clash in any UNIX
  152. implementation.  The difficulty being that the sources often include
  153. both string.h/memory.h, and the declarations that are part of
  154. malloclib.  I got around this problem by simply deleting the includes
  155. of <string.h>/<memory.h> in the malloclib source.
  156.  
  157. As the documentation indicates, malloclib is rather slow, so it should
  158. not be included in production binaries.  In my relatively limited
  159. testing, one program which took 10 CPU minutes with the standard system
  160. malloc took over 1200 CPU minutes with malloclib before I killed it.
  161. (This may be a bug in malloclib - a factor of over 100 seems a bit
  162. unreasonable, but I was unable to investigate further.  The program
  163. malloc's a LOT of space in small pieces)
  164.  
  165. ------------------------------------------------------------------------
  166.  
  167. It took a little twiddling before I could make it work on a Sun.
  168. ...
  169. The library is valuable and deserves to be published.  
  170. ...
  171. Luckily, this package is only for use by C programmers so it's not all
  172. that unfair to expect some troubleshooting skills of the person trying
  173. to build it.
  174.  
  175. exit 0 # Just in case...
  176.