Dmalloc Logo
Home

Documentation
Downloads
Forums
Releases

Search this site:

Donations:
If dmalloc has saved you or your company time or money, please use your credit-card or PayPal account to donate to the cause.

Dmalloc Tutorial: 3.5 Description of the Internal Error Codes
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5 Description of the Internal Error Codes

The following error codes are defined in `error_val.h'. They are used by the library to indicate a detected problem. They can be caused by the user (`ERROR_TOO_BIG') or can indicate an internal library problem (`ERROR_SLOT_CORRUPT'). The `dmalloc' utility can give you the string version of the error with the -e argument:

 
$ dmalloc -e 60
dmalloc: dmalloc_errno value '60' = 
   'pointer is not on block boundary'

Here are the error codes set by the library. They are non contiguous on purpose because I add and delete codes all of the time and there are sections for various error-code types.

1 (ERROR_NONE)

No error. It is good coding practice to set the no-error code to be non-0 value because it forces you to set it explicitly.

2 (INVALID_ERROR)

Invalid error number. If the library outputs this error however the dmalloc utility says that it is invalid then your dmalloc utility may be out of date with the library you linked against. This will be returned with all error codes not listed here.

10 (ERROR_BAD_SETUP)

Bad setup value. This is currently unused but it is intended to report on invalid setup configuration information.

11 (ERROR_IN_TWICE)

Library went recursive. This usually indicates that you are not using the threaded version of the library. Or if you are then you are not using the `-o' "lock-on" option. See section Using the Library with a Thread Package.

13 (ERROR_LOCK_NOT_CONFIG)

Thread locking has not been configured. This indicates that you attempted to use the `-o' "lock-on" option without linking with the thread version of the library.

20 (ERROR_IS_NULL)

Pointer is null. The program passed a NULL (0L) pointer to free and you have the `error-free-null' token enabled.

21 (ERROR_NOT_IN_HEAP)

Pointer is not pointing to heap data space. This means that the program passed an out-of-bounds pointer to free or realloc. This could be someone trying to work with a wild pointer or trying to free a pointer from a different source than malloc.

22 (ERROR_NOT_FOUND)

Cannot locate pointer in heap. The user passed in a pointer which the heap did not know about. Either this pointer was allocated by some other mechanism (like sbrk directly) or it is a random invalid pointer.

In some rare circumstances, sometimes seen with shared libraries, there can be two separate copies of the dmalloc library in a program. Each one does not know about the pointers allocated by the other.

23 (ERROR_IS_FOUND)

This indicates that the pointer specified in the address part of the environmental variable was discovered by the library. See section Environment Variable Name and Features. This error is useful so you can put a breakpoint in a debugger to find where a particular address was allocated. See section Using Dmalloc With a Debugger.

24 (ERROR_BAD_FILE)

A possibly invalid filename was discovered in the dmalloc administrative sections. This could indicate some corruption of the internal tables. It also could mean that you have some super long filename which was returned by __FILE__. See MAX_FILE_LENGTH in the `settings.dist' file.

25 (ERROR_BAD_LINE)

A line-number was out-of-bounds in the dmalloc administrative sections. This could indicate some corruption of the internal tables. It also could mean that you have some super long file with more than 10000 lines. See MAX_LINE_NUMBER in the `settings.dist' file.

26 (ERROR_UNDER_FENCE)

This indicates that a pointer had it's lower bound picket-fence magic number overwritten. If the `check-fence' token is enabled, the library writes magic values above and below allocations to protect against overflow. Most likely this is because a pointer below it went past it's allocate and wrote into the next pointer's space.

27 (ERROR_OVER_FENCE)

This indicates that a pointer had it's upper bound picket-fence magic space overwritten. If the `check-fence' token is enabled, the library writes magic values above and below allocations to protect against overflow. Most likely this is because an array or string allocation wrote past the end of the allocation.

Check for improper usage of strcat, sprintf, strcpy, and any other functions which work with strings and do not protect themselves by tracking the size of the string. These functions should always be replaced with: strncat, snprintf, strncpy, and others.

28 (ERROR_WOULD_OVERWRITE)

This error is generated by the function pointer checking code usually enabled wit the check-funcs token. Dmalloc overloads a number of string and memory copying functions and verifies that the buffers (if allocated in the heap) would not be overwritten by the function.

30 (ERROR_NOT_START_BLOCK)

This indicates that the user passed in a pointer to be freed or reallocated that was not at the start of the allocation. You would get this error, for example, if you allocate and get pointer X but then try to free X+1.

40 (ERROR_BAD_SIZE)

This error indicates that a size value in the internal structures of the library were corrupted. This could be a random pointer problem, pointer overflow, or some other corruption.

41 (ERROR_TOO_BIG)

An allocation asked for memory larger than the configured maximum. This is a user configured setting. See LARGEST_ALLOCATION in the `settings.dist' file. It is used to protect against wild allocation sizes. If you have super large allocation sizes then you should tune the LARGEST_ALLOCATION value appropriately.

43 (ERROR_ALLOC_FAILED)

The library could not allocate more heap space and the program has run out of memory. This could indicate that you've overflowed some system imposed limit. On many operation systems, the ulimit call can tune system defaults.

44 (ERROR_ALLOC_NONLINEAR)

If the force-linear token is enabled, the library will ensure that the heap memory returned, is linear and contiguous. This should only be used in special circumstances.

45 (ERROR_OVER_LIMIT)

The library has allocated more memory than was specified in the memory-limit environmental variable. See section Environment Variable Name and Features.

60 (ERROR_NOT_ON_BLOCK)

The user tried to free or realloc a pointer that was not pointing to a block boundary. You would get this error, for example, if you allocate and get pointer X but then try to free X+1.

61 (ERROR_ALREADY_FREE)

The user tried to free a pointer than has already been freed. This is a very common mistake and can lead to serious problems. It can be because a destructor is being called twice for some reason. Although tracking down the specific source is highly recommended, it is good to set pointers to NULL (0L) after you free them as a rule.

67 (ERROR_FREE_OVERWRITTEN)

If either the free-blank or check-blank tokens are enabled then the library will overwrite memory when it is freed with the "dmalloc-free" byte (hex 0xdf, octal 0337, decimal 223). If the program writes into this space, then the library will detect the write and trigger this error. This could indicate that the program is using a pointer after it has been freed.

70 (ERROR_ADMIN_LIST)

An internal corruption in the library's administrative structures has been detected. This could be a random pointer problem, pointer overflow, or some other corruption.

72 (ERROR_ADDRESS_LIST)

An internal corruption in the library's administrative structures has been detected. This could be a random pointer problem, pointer overflow, or some other corruption.

73 (ERROR_SLOT_CORRUPT)

An internal corruption in the library's administrative structures has been detected. This could be a random pointer problem, pointer overflow, or some other corruption.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated by Gray Watson on May, 16 2007 using texi2html 1.76.

This work is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.
This page should be W3C Valid XHTML and should work with most browsers.