home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / dbmalloc.zip / PROBLEMS < prev    next >
Text File  |  1993-01-04  |  13KB  |  304 lines

  1.  
  2. This file documents the problems that have been found when the library
  3. is ported to different machines.  Where possible, a generic solution
  4. has been added to the library so that the problem does not re-occur.
  5.  
  6. NOTES specific to a particular implementation are included at the end
  7. of this file.  Search for ^SYSTEM if you want to jump to them:
  8.  
  9. 0. Configure script has a problem
  10.     
  11.     One note about problems with configure is that they are frequently
  12.     caused by someone who has installed an ansi compiler like gcc and
  13.     hasn't changed the system include files accordingly.
  14.  
  15.     Configure will attempt to guess at the correct settings even if it
  16.     is not able to determine if they are correct.  Theses guessed at 
  17.     settings will be flaged by a '/* *GUESS* */' to the right of the
  18.     definition and should be reviewed to make sure they are right.
  19.  
  20.     If this happens, you should determine if the problem is a problem
  21.     with the script itself, or with the script being able to determine
  22.     the correct settings for your compiler/os combination.  
  23.  
  24.     If you find that it is a bug in the script, please report it to 
  25.     the author so that the fix can be incorporated into future releases.
  26.     This is most likely the cause of a problem.  You should pay 
  27.     particular attention to the fact that Configure *guesses* that it
  28.     found the correct settings by compiling a test module and verifying
  29.     that there were no warning messages generated.  It is possible that
  30.     you have a strict ANSI compiler that is warning about something in
  31.     the test file cctest.c which really has nothing to do with the 
  32.     Configuration.
  33.     
  34.     If, however, the script appears to be processing the data correctly,
  35.     but is still unable to determine the correct settings for your system
  36.     you will have to configure the file by hand.  This involves the
  37.     following steps:
  38.  
  39.     A) create .configure file that contains the following lines
  40.  
  41.         #define VOIDTYPE     <voidtype>
  42.         #define CONST        <const>
  43.         #define DATATYPE    <malloc_datatype>
  44.         #define SIZETYPE    <malloc_sizetype>
  45.         #define MEMDATA        <mem_datatype>
  46.         #define MEMSIZE        <mem_sizetype>
  47.         #define MEMCMPTYPE    <mem_comptype>
  48.         #define STRSIZE        <str_sizetype>
  49.         #define STRCMPTYPE    <str_comptype>
  50.  
  51.     where
  52.  
  53.         voidtype        is void if your compiler understands
  54.                 void data types, int otherwise
  55.         const        is const if your compiler understands
  56.                 constant variables
  57.         malloc_datatype    is the base type of the pointer returned by
  58.                 malloc (usually char or void)
  59.         malloc_sizetype    is the type of the size argument used by
  60.                 malloc and its associates (usually size_t,
  61.                 int, or unsigned int)
  62.         mem_datatype    is the base type of the pointer returned by
  63.                 the mem* functions (like memcpy()). This is
  64.                 usually char or void.
  65.         mem_sizetype    is the type of the len argument used by
  66.                 the mem* functions (usually size_t,
  67.                 int, or unsigned int).
  68.         mem_comptype    type to be used for comparisons of the differing
  69.                 characters in the memory comparison functions.
  70.                 This will usually be char or unsigned char. ANSI
  71.                 C says it will be unsigned char.
  72.         str_sizetype    is the type of the len argument used by
  73.                 the str* functions (like strncpy()).  This is
  74.                 usually size_t, int, or unsigned int.
  75.         str_comptype    type to be used for comparisons of the differing
  76.                 characters in the string comparison functions.
  77.                 This will usually be char or unsigned char. ANSI
  78.                 C says it will be unsigned char.
  79.  
  80.     B) create .configure.s file that contains the following lines:
  81.  
  82.         #define ABORT_SIGNAL    <abortsignum>
  83.         #define WRTSIZE        <write_sizetype>
  84.  
  85.     where
  86.     
  87.         abortsignum        is the signal number used to abort a program.
  88.                 This is usually SIGABRT or SIGIOT.
  89.         write_sizetype    is the type of the size (or length) parameter
  90.                 to the write system call.  This will usually
  91.                 be size_t, unsigned int, or int
  92.  
  93.     In addition
  94.  
  95.         if your compiler/libraries do not support the putenv() 
  96.         call, but instead support setenv(), add the following line:
  97.  
  98.             #define USE_SETENV 1
  99.  
  100.         If your system has an Intrinsic.h file in /usr/include/X11,
  101.         add the following line:
  102.  
  103.             #define FOUND_X_INTRINSIC 1
  104.  
  105.         If wait.h is available for wait() system call parameter 
  106.         definitions, add the following line:
  107.     
  108.             #define NEED_WAIT 1
  109.     
  110.         If you are running X11R4 or before and you intend to use the
  111.         library to link with X programs, add the following line:
  112.  
  113.             #define DONT_FORCE_HEAPSTUFF 1
  114.  
  115.     C) If you want to preclude the use of the system memset and memcpy
  116.     modules (which if they can be used will usually result in a 
  117.     significant performance gain), create a .configure.O (capital letter o)
  118.     file with something in it (i.e. date > .configure.O).
  119.  
  120.     D) run Configure to generate the appropriate .h files (and if you
  121.     didn't create the .configure.O file in step C, the converted system
  122.     memset and memcpy routines, if they are compatible and useful)
  123.  
  124.     NOTE: Configure attempts to grab the memset.o and memmove(or memcpy)
  125.     routines from libc.a, if it can find them, and convert them for
  126.     use by the library since these modules are usually modified by the
  127.     vendor so that they take advantage of assembly language features
  128.     to improve performance. 
  129.  
  130.     If libc.a cannot be found, or if the system modules are not compatible
  131.     with the malloclib versions (this frequently happens with memcpy since
  132.     the malloclib version correctly handles moving data around in
  133.     overlapped regions), then Configure will not include them and the
  134.     library will include its own version (which has been optimized in a
  135.     portable fashion).
  136.  
  137.     If the files datamc.O and datams.O do not get created, then this was
  138.     the case.  You can improve the performance of the library significantly
  139.     by coding compatible libraries in assembly language if your cpu
  140.     has specialized data movement instructions.  See the datamc.c routine
  141.     for a sample of such a mechanism used to optimize memcpy() operations
  142.     on a 386.
  143.  
  144.     If you do this, and it passes all of the tests (including the 1,000,000
  145.     allocation test for testmalloc), please send it in and I will include
  146.     it in the next release.
  147.  
  148.  
  149. 1. Compilation problems with the library itself.
  150.  
  151.     This is a fairly common problem and is most often associated with
  152.     the settings for the .configure #defines.  If you get any compilation
  153.     errors for modules within this library, the first thing you should
  154.     do is verify that you are using the correct settings for these
  155.     typedefs.  Review the description on what they should be set to and 
  156.     review the original settings.
  157.  
  158.     Another common problem is attempting to compile the library and/or
  159.     test with a strict ANSI-C compiler.  Since ANSI reserves symbols
  160.     like malloc, memcpy, strcpy, etc you can expect to have a lot of
  161.     problems.  This is especially so if the ANSI is very strict 
  162.     because the library does make use of UNIX functionality like fork,
  163.     wait, open, write, etc.
  164.  
  165.     If you have access to an standard K&R compiler (or a more relaxed 
  166.     ANSI compiler, especially one that uses the system K&R style header
  167.     files (i.e. gcc without -pedantic on a system with a non-ANSI cc)
  168.     you should use it to compile the library.  Once the library is
  169.     compiled, you should be able to use it with code compiled under
  170.     other compilers (assuming, of course, that they are compatible).
  171.     
  172.  
  173. 2. Conflicts with system provided string.h/memory.h includes
  174.  
  175.     The library provides its own versions of these functions, but includes
  176.     the system header files so that if it compiles with no errors, you
  177.     will know that the two agree exactly.   The Configure script should
  178.     have ensured that they agreed, but is it possible that it got them
  179.     wrong.  Check the .configure file to determine if the #defines are
  180.     set correctly (as described in step 0)
  181.  
  182. 3. Duplicate symbols from libc.a (or its equivalent shared library)
  183.  
  184.     This is most often caused by one of the system library functions
  185.     including an additional function/variable definition in one of the
  186.     memory/string library modules. (i.e. some systems have a cfree()
  187.     call that is in the calloc.o library module).
  188.  
  189.     There are several ways to get around this problem.  The best way
  190.     would be to duplicate the functionality of the extra reference 
  191.     where ever it is appropriate in the malloc library (similarly to
  192.     the addition of cfree in the calloc.c module).   If you do this,
  193.     please send me the new function and a description of the system and/or
  194.     compiler so that I can determine if it should go into the standard
  195.     distribution.
  196.  
  197.     Another mechanism that has been reportedly used in some architectures
  198.     is to ignore the duplicate symbol errors and just chmod the executable
  199.     so that it is executable (i.e. chmod +x).  I don't know if this is 
  200.     all that safe, or if it will work on your system, but it has been 
  201.     reported to successfully work in this fashion.
  202.     
  203.     Another, less desirable way would be to disable the offending function
  204.     in this library.  This option is less desirable because the disabled
  205.     function would no longer provide any error checking (which is 
  206.     supposed to be the purpose of this library).
  207.  
  208.     With shared libraries, there are some formats (perhaps all) that
  209.     have explicit references to functions in the shared library that
  210.     are duplicated in the debug library.  On these systems, the
  211.     only way around the problem is to not use the shared library 
  212.     when linking the test version of the software.
  213.  
  214. 4. Compilation errors in string.c and/or memory.c
  215.  
  216.     There are several compilers that provide in-line expansion of
  217.     routines like strcpy.  This can cause real problems when we 
  218.     try to compile our own version.  If you can disable the in-line
  219.     expansion, that is the best way to go.  This should only be
  220.     needed for the malloc library itself.  The source you are debugging
  221.     should include the malloc.h file and therefore won't be calling
  222.     strcpy, but instead will be calling DBstrcpy (because of a macro
  223.     in malloc.h).
  224.  
  225.     Disabling the in-lining of functions is usually accomplished by
  226.     setting a compiler flag, or sometimes by predefining some #def
  227.     that is used by system include files.
  228.  
  229.     If you can't disable the in-line expansion, you will have to 
  230.     disable the debug versions of the offending functions in the
  231.     malloc library by adding a #ifdef around the code.  Be sure to
  232.     just disable the functions that are giving you problems (i.e. don't
  233.     disable all of string.c and don't disable the DB functions, because
  234.     any code that includes malloc.h will attempt to use them).
  235.  
  236. 5. Conflicts/problems with prototypes.h
  237.  
  238.     Prototypes.h is a generated file that has zillions of function
  239.     prototypes for the malloc library.  You should not need to remake
  240.     this module.  If, however, you have made changes to the calling
  241.     arguments for some of the functions due to conflicts with system
  242.     headers, you may have to modify or rebuild this file.
  243.  
  244.     To rebuild the file using the makefile targets you must have the
  245.     cproto prototype generator (available in comp.sources.misc, vols 17
  246.     and 18).
  247.  
  248. 6. Argument mis-matches and syntax errors when including malloc.h
  249.  
  250.     This is usually the result of including malloc.h before string.h
  251.     and/or memory.h which causes lots of problems.  malloc.h attempts
  252.     to avoid this problem by #defining a bunch of typical symbols used
  253.     to preclude multiple inclusions of these files, but some systems do
  254.     not have this multiple inclusion protection, or use a slightly 
  255.     different symbol for the protection.
  256.  
  257.     To get around this problem you could do one of the following:
  258.  
  259.         1. change the code so that it includes malloc.h last.
  260.         2. add multiple inclusion protection to the system include
  261.            files.
  262.         3. remove the #defines from malloc.h (which decreases the
  263.            ability for the debug library to identify the source of
  264.            the problems).
  265.  
  266.     Another problem with including malloc.h will occur if you have local
  267.     definitions of things like:
  268.  
  269.             char * strcpy();
  270.     
  271.     which will result in a preprocessor or compiler error because of the
  272.     #defines in malloc.h.  The recommended solution to this problem is
  273.     to remove the local definitions and include the system header files
  274.     that have the definitions (string.h in this case).  If you can't or
  275.     don't want to do this, you can add #ifndef _DEBUG_MALLOC_INC and 
  276.     #endif around the local definitions so that they are not included if
  277.     the debugging version of malloc.h is included.
  278.  
  279.     Yet another similar problem is the use of standard symbols for variable
  280.     and/or structure element names.  This happens most often with the
  281.     variable index. 
  282.  
  283.     To fix this, you can change the name of the variable, #undef index
  284.     after including the malloc library, or remove the #define index
  285.     line from malloc.h
  286.  
  287. **************************************************************************
  288. SYSTEM SPECIFIC PROBLEMS
  289.  
  290.  
  291. Sun Sparc w/ SunOS 4.x and GCC 2.1
  292.  
  293.     The header files provided by sun do not contain ansi standard 
  294.     definitions for many of the modules used by the library and cause
  295.     problems when included by code compiled by GCC.  This includes
  296.     things like <memory.h> which has a prototype for memcpy which
  297.     is something like void * memcpy(); and doesn't agree with the
  298.     builtin definition in gcc (void * memcpy(void *, const void*, int)).
  299.  
  300.     The solution to this problem would be to define the correct
  301.     prototypes for memory.h in the system include file or in the
  302.     gcc version of the include file. 
  303.  
  304.