Chapter 11
Error Messages
This chapter describes the error messages that Memory Advisor issues.
Introduction
Whenever Memory Advisor detects an error, it reports a message. Certain key elements are present in every message:
- The message type:
- The mnemonic error class and numeric error code (enclosed in square brackets), which provide a quick identification for the message Memory Advisor is generating.
- The descriptive message, which contains a description of the error or information you are requesting. It may contain addresses of the allocated memory areas, the size of the memory area, the number of bytes being read/written, and the operation being attempted.
- The stack trace, which indicates the stack context where Memory Advisor detected the condition and reported the message. If you compiled your program with the -g option, the stack trace also includes file names and line numbers. Stack traces do not appear for Info error class messages.
- If the error is associated with an allocation, the stack trace where your program allocated the memory segment involved in the error. The stack trace indicates the stack context where your program allocated the memory segment. If you compiled your program with the -g option, the stack trace also includes file names and line numbers.
- The stack trace where your program freed the memory segment involved in the error, if it freed it. The stack trace indicates the stack context where your program freed the memory segment. If you compiled your program with the -g option, the stack trace also includes file names and line numbers.
Error Classes
The following sections provide a description of each mnemonic error class, followed by a discussion of specific causes of the error, if necessary.
AccFreed
You attempted to access memory that is already freed. You can receive this message under the following circumstances:
AccInvalid
You attempted a memory reference with an invalid pointer. You can receive this message under the following circumstances:
AccNull
You attempted a memory reference with a null pointer.
AccOutOfBounds
You tried to reference memory outside the allocated memory segment (an underwrite, overwrite, or both). You can receive this message under the following circumstances:
AccUninit
You attempted to read uninitialized memory, or you attempted a memory reference with an uninitialized pointer.
Alloc
There is a problem with the allocator that your program is using. For example, a call to the malloc() function returns an address that is already in use elsewhere in your program.
BadAlign
You called the memalign() function with a bad alignment. The alignment you specify must be a multiple of two and be larger than the size of a word.
BadDisposal
You attempted to discard memory with a function that does not match the allocator function. For example, you allocated the memory with the malloc() function and tried to free it with the C++ delete operator.
BadUnmap
Your program called the munmap() function with an address that does not correspond to an address returned by a prior call to the mmap() function.
BadUsage
You made an error in using a Memory Advisor function. Typically this manifests when you pass an invalid file descriptor to one of the API calls.
Config
There is a problem with a configuration file or configuration option in the environment. Causes for this error or warning include:
FileDesc
The FileDesc mnemonic is a placeholder for the individual entries in an open file descriptor report. You may use this mnemonic coupled with a stack context to exclude entries from the open file descriptor report.
FreeBad
You attempted to free a memory segment that you previously marked as permanent with a call to the MaLeakPtrNotALeak() function.
FreeNull
You passed a null pointer to a deallocation function that does not accept null pointers.
Info
Memory Advisor is reporting information to you.
Internal
A Memory Advisor internal error occurred. Please capture the error output, try to reproduce it in a small test case, and send the output and test case to PLATINUM Technical Support.
Leak
The Leak mnemonic is a placeholder for individual entries in a leak report. You may use this mnemonic coupled with a stack context to exclude entries from the report.
License
A Memory Advisor licensing error or warning occurred. You can get this warning for several reasons:
MaxAlloc
You tried to allocate more memory in a single block than MA_MAX_ALLOCATION allows.
Misc
An otherwise unclassified event occurred.
Overlap
You tried to perform an overlapping copy of two memory areas.
Signal
Your program received a signal that is either a fatal signal or one for which your program did not install a handler.
String
You tried to manipulate a non-null-terminated string with a string function.
ThreadSync
A thread-locking error occurred.
UsrAlloc
An error has occurred in the integration of your user-defined memory allocator with Memory Advisor. Messages of this class come from the MaUsrAlloc*() functions.
Watch
A Memory Advisor watchpoint event occurred. Memory Advisor informs you every time you add or remove a watchpoint, when the watchpoint function return value changes, or when a memory event occurs at the watchpoint.
ZeroAlloc
You tried to allocate a zero-length block of memory.
Error Codes
The following sections provide a description of each numeric error code, followed by a discussion of specific causes of the error, if necessary.
Error Message 11
Class: AccOutOfBounds
Type: Fatal
You should not receive error message 11. It is a fatal, internal error. If you receive this message, please contact PLATINUM Technical Support for further instructions.
Note: You cannot exclude this error message.
Error Message 12
Class: AccOutOfBounds
Type: Fatal
You should not receive error message 12. It is a fatal, internal error. If you receive this message, please contact PLATINUM Technical Support for further instructions.
Note: You cannot exclude this error message.
Error Message 13
Class: ZeroAlloc
Type: Warning
You attempted to allocate a zero-length memory segment. Error message 13 is a portability warning, not an error. You receive this warning only when you explicitly set the MA_WARN_ZERO_ALLOC option to on. It is off by default. For example:
char * string;
string = (char *) malloc(0); /* Error 13 */
Allocating zero-length memory segments is legal according to the ANSI C specification. Each allocation of zero bytes returns a non-null pointer that is distinct from all other allocations of zero bytes.
If you are concerned about portability, there are certain compilation environments whose behavior is different from the ANSI standard. For portability, you should disallow zero-byte allocations.
Error Message 14
Class: AccOutOfBounds
Type: Warning
You receive error message 14 when you attempt to access memory beyond the end of an allocated segment. For example:
char * buf3 = (char *) malloc(10);
strcpy(buf3, "0123456789"); /* Error 14 */
In this example, you are trying to write 11 bytes (10 characters plus the null termination byte) into a 10-byte-long memory segment.
This message indicates a definite error in your code. The solution is generally obvious from the information given in the message about where the problem occurred.
Common causes of this problem are:
Error Message 15
Class: AccOutOfBounds
Type: Warning
You receive error message 15 when you underrun an allocated memory segment. For example:
char * str = (char *) malloc(10);
strcpy (str - 5, "foo"); /* Error 15 */
This message indicates a bad pointer. It sometimes results from an incorrect address computation, and at other times it occurs because your program overwrote the actual pointer value.
Error Message 16
Class: AccFreed
Type: Warning
Error message 16 indicates that you are trying to access a freed memory segment. For example:
char * string;
string = (char *) malloc(15);
free(string);
strcpy(string, "foo"); /* Error 16 */
In this example, you freed string and then you tried to copy into the freed memory segment.
This message indicates a definite error in your program. The message tells you where you tried to access the freed memory and, usually, where you freed the memory. You should use this information to remedy the problem.
Rarely, if your program freed the memory so long before accessing it that it has since reused the memory, Memory Advisor will not be able to tell you where your program freed it. In this case, if it is not obvious where your program freed the memory, you may want to increase the value of the MA_FIFO_LENGTH option to increase the size of the internal FIFO queue that Memory Advisor uses to track freed segments.
Error Message 17
Class: AccOutOfBounds
Type: Fatal
You should not receive error message 17. It is a fatal, internal error. If you receive this message, please contact PLATINUM Technical Support for further instructions.
Note: You cannot exclude this error message.
Error Message 18
Class: AccOutOfBounds
Type: Fatal
You should not receive error message 18. It is a fatal, internal error. If you receive this message, please contact PLATINUM Technical Support for further instructions.
Note: You cannot exclude this error message.
Error Message 19
Class: AccInvalid
Type: Warning
You receive error message 19 when you use a pointer that is not on an appropriate boundary for your machine or a pointer that is not allocated. For example:
char buf[14];
main()
{
char * str;
str = (char *) malloc(10);
free(str + 1); /* Error 19 */
free(buf); /* Error 19 */
}
In this example, passing an odd pointer to free() and passing a pointer that you have not allocated to free() cause this message.
This message indicates a programming error. You should be able to find and resolve the problem using the stack trace information that Memory Advisor provides.
Error Message 20
Class: AccFreed
Type: Warning
Error message 20 indicates that you are freeing a pointer that is already free. For example:
char * string;
string = (char *) malloc(15);
free(string);
free(string); /* Error 20 */
The error message should give you the location where your program first freed the pointer. Use this information to determine where best to free the pointer so that you only free it once.
It is possible that the message may not give a stack trace for where your program first freed the pointer. Free segments go into an internal FIFO queue for a time before actually being returned to the system. If the free segment has fallen out of the queue, you may not receive the stack trace for the first free. Try to increase the size of the queue using the MA_FIFO_LENGTH option.
If this does not work, set a conditional breakpoint on the free() function in your debugger, where the condition checks to see if the parameter passed to free() has the same value as the one reported in the message.
Error Message 22
Class: AccOutOfBounds
Type: Warning
You receive error message 22 if your program somehow manages to corrupt the data boundary area before an allocated segment. For example:
char * str = (char *) malloc(10);
sprintf(str, "123456789");
strcpy(str - 6, str + 6); /* Error 22 */
This message indicates a programming error. You should find the location of the problem between the first stack trace in the message and the stack trace of the previous message. You may need to trace the problem in a debugger to find the cause of the problem.
Error Message 23
Class: AccOutOfBounds
Type: Warning
Memory Advisor prints error message 23 when your program modifies a boundary area after a pointer. For example:
char * str = (char *) malloc(10);
str[11] = 'a'; /* Error 23 */
This message indicates a programming error. From the error message, you should be able to determine the point at which your program modified the boundary area.
Common causes for this message are:
Error Message 24
Class: AccFreed
Type: Warning
Memory Advisor prints error message 24 when it discovers a corrupted, freed memory segment during chain-checking. During the chain check, Memory Advisor verifies that memory segments you freed are still filled with the free fill pattern (MA_MEM_FREE_FILL). If this is not the case, you receive this message. You can use a watchpoint to help find where you reused this memory.
Error Message 25
Class: FreeNull
Type: Warning
You attempted to free a null pointer. Error message 25 is a portability warning, not an error. You receive this warning only when you explicitly set MA_WARN_NULL_PTR to on. MA_WARN_NULL_PTR is off by default. For example:
char * string;
string = (char *) NULL;
free(string);
Freeing a null pointer is legal according to the ANSI C specification. If you are concerned about portability, there are certain compilation environments whose behavior is different from the ANSI standard. For portability, you should not allow the freeing of null pointers.
Error Message 26
Class: FreeBad
Type: Warning
Memory Advisor produces error message 26 when you try to free a pointer that you marked as a nonleak.
For example:
char * str = (char *) malloc(10);
MaLeakPtrNotALeak(str);
free(str); /* Error 26 */
When you call the MaLeakPtrNotALeak() function, either from your program or the debugger, you are telling Memory Advisor that you do not intend to free the pointer that you passed to MaLeakPtrNotALeak(). This message tells you that you have freed that pointer. This may or may not indicate a programming error.
You will only see this message when you set the MA_WARN_FREE_MARK option to on. This option is off by default.
Error Message 27
Class: Internal
Type: Warning
You receive error message 27 when the operating system refuses to allow an allocation. This message generally indicates one of the following:
Be aware that the behavior of both Memory Advisor and your program are undefined after Memory Advisor reports this message.
Error Message 28
Class: Overlap
Type: Warning
You receive error message 28 when you try to perform an overlapping copy of memory and you set the MA_WARN_OVERLAP option to on. This is a portability warning. For example:
st = (char *) malloc(24);
strcpy(st, "the quick red fox jumps");
p1 = st;
p2 = (char *) strchr(st, 'r');
memcpy(p2, p1, 12); /* Error 28 */
In this example, there are two overlapping memory segments being copied. The start of the second segment (p2) is only 10 bytes from the start of the first segment, so the resulting 12-byte copy will overlap by 2 bytes.
The memcpy() function does not support overlapping copies. You can use the memmove() function instead, if it is available on your platform.
In general, you should not ignore this warning. You should recode to avoid the overlapping copy.
Error Message 29
Class: Internal
Type: Fatal
Memory Advisor issues error message 29 when it is generating a full error report about a broken stack frame. Memory Advisor does not issue this message by default. You must request this message by asking Memory Advisor to print a broken stack report with the MA_STACK_BROKE_REPORT option.
Stacks can often appear broken (while they are actually functional) for several reasons:
In evaluating a potential broken stack, you should look for abnormal program behavior, especially when trying to return through the broken frame. If this is the case, you should be able to start tracking the problem with the information provided in the error message.
Error Message 30
Class: Config
Type: Warning
Error message 30 indicates that a value for one of Memory Advisor's configuration options passed in an environment variable is incorrect. For example:
MA_MATCH_ALLOC=junk a.out
The message tells you the name of the option and the value that Memory Advisor does not like. If the solution is not obvious, see Chapter 8, Configuration Options, for the specific option's valid values.
Error Message 31
Class: Config
Type: Warning
Error message 31 indicates that Memory Advisor found an invalid value for a configuration option in one of your configuration files. For example:
MA_WARN_NULL_PTR=always
In this example, ``always'' is not a valid value for the MA_WARN_NULL_PTR option.
The error message indicates the file and the location at which the error occurred. If the solution is not obvious, see Chapter 8, Configuration Options, for the specific option's valid values.
Error Message 32
Class: Config
Type: Warning
Error message 32 indicates that Memory Advisor had difficulty parsing one of your configuration files. For example:
MA_WARN_NULL_PTR:on
In this example, Memory Advisor does not recognize the colon (:). It expects an equal sign (=) to delimit the option from its value. This error almost always results from a typographical error.
The error message indicates the file and the location at which the error occurred. If the solution is not obvious, send a copy of your configuration file to PLATINUM Technical Support.
Error Message 33
Class: Config
Type: Warning
Error message 33 indicates that Memory Advisor found an invalid configuration option in one of your configuration files. For example:
MA_INVALID_OPTION=always
In this example, MA_INVALID_OPTION is not a valid option for Memory Advisor.
The error message indicates the file and the location at which the error occurred. See Chapter 8, Configuration Options, for the correct spelling of the option you are trying to set.
Error Message 34
Class: Config
Type: Warning
Error message 34 indicates that Memory Advisor could not open the file path that you specified in the MA_CONFIG_FILE environment variable. For example:
MA_CONFIG_FILE=/does/not/exist a.out
Check that the file exists and that you have the appropriate permissions to open it.
Error Message 35
Class: AccNull
Type: Warning
Memory Advisor prints error message 35 when you use a null pointer to access memory. For example:
char *a = 0;
char *b = 0;
if( strcmp(a,b) == 0 ) /* Error 35 */
{
}
This message almost certainly indicates a programming error. You should be able to find and correct the problem from the stack trace printed with the error message.
Memory Advisor only prints this message when you set the MA_WARN_BAD_PTR option to on, which it is by default.
Error Message 36
Class: AccUninit
Type: Warning
Memory Advisor prints error message 36 when your program uses an uninitialized pointer to access memory. For example:
struct s
{
char * p;
};
main()
{
char * ptr = (char *) malloc(100);
struct s * str = (struct s *) malloc(sizeof(struct s));
strcpy(ptr, str->p); /* Error 36 */
}
This message indicates a programming error. Using the stack trace in the message, you should find and correct the problem.
You receive this message only when the MA_WARN_BAD_PTR option is on, which it is by default.
Error Message 37
Class: AccFreed
Type: Warning
Memory Advisor prints error message 37 when your program uses a freed pointer to access memory. For example:
struct s
{
char * p;
};
main()
{
char * ptr = (char *) malloc(100);
struct s *str = (struct s *) malloc(sizeof(struct s));
free(str);
strcpy(ptr, str->p); /* Error 37 */
}
This message indicates a programming error. Using the stack trace in the message, you should find and correct the problem.
You receive this message only when the MA_WARN_BAD_PTR option is on, which it is by default.
Error Message 40
Class: AccUninit
Type: Warning
Memory Advisor prints error message 40 when you try to access uninitialized data. For example:
char * path = (char *) malloc(64);
rtn = mkdir(path, 755); /* Error 40 */
This message indicates a programming error. Using the stack trace in the error message, you should determine why your program did not initialize the data area between its allocation and its use.
Error Message 41
Class: Watch
Type: Info
Memory Advisor prints error message 41 when it determines that your program modified a memory location for which you set a watchpoint.
This message is the expected result of setting a watchpoint with the MaWatchAdd() function. Using the stack trace where Memory Advisor detected the watchpoint change and the stack trace where Memory Advisor last noted the unchanged data, you should be able to determine exactly how your program modified the data.
Error Message 42
Class: Watch
Type: Info
Memory Advisor produces error message 42 when your program reads the data at the watchpoint you installed.
Error Message 43
Class: Watch
Type: Info
Memory Advisor produces error message 43 when your program writes the data at the watchpoint you installed.
Error Message 45
Class: Watch
Type: Info
Error message 45 is a confirmation from the MaWatchAdd() function that it succeeded in installing the watchpoint you requested. For example:
(dbx) print MaWatchAdd(&t, 12, "write")
Note: You cannot exclude this error message.
Error Message 46
Class: Watch
Type: Info
Error message 46 is a confirmation from the MaWatchRemove() function that it succeeded in removing the watchpoint you requested. For example:
(dbx) print MaWatchRemove(&t)
Note: You cannot exclude this error message.
Error Message 47
Class: Watch
Type: Info
Error message 47 indicates that the MaWatchAdd() function could not add the watchpoint you requested. For example:
(dbx) print MaWatchAdd(&t, 4, "typo")
The usual cause of this message is one or more invalid arguments to MaWatchAdd(). MaWatchAdd() takes three arguments:
Error Message 48
Class: Watch
Type: Info
You receive error message 48 when Memory Advisor has reloaded a watchpoint. This generally occurs when you restart a program from inside your debugger.
When you restart the process you are debugging, Memory Advisor reloads all currently active watchpoints. If you no longer need these watchpoints, you may remove them with the MaWatchRemove() function. If you do not want this behavior, set the MA_WATCHPOINT_SAVE option to off.
Error Message 49
Class: Watch
Type: Info
Memory Advisor prints error message 49 when you try to recursively invoke a watchpoint function. You should receive this message only under extremely precise conditions:
To work around this, make sure that you are not executing functional watchpoint code when trying to invoke a Memory Advisor watchpoint function.
Note: You cannot exclude this error message.
Error Message 50
Class: Internal
Type: Warning
You should not receive error message 50. It is a fatal, internal error. If you receive this message, please contact PLATINUM Technical Support for further instructions.
Note: You cannot exclude this error message.
Error Message 51
Class: License
Type: Warning
Memory Advisor produces error message 51 when your evaluation license has expired. You will see this message if:
If you are evaluating Memory Advisor and feel you need more time to conduct your evaluation, please ask your Memory Advisor sales representative about receiving a license extension.
Note: You cannot exclude this error message.
Error Message 52
Class: License
Type: Warning
You receive error message 52 when you are using an evaluation license. It tells you when the license will expire. You can suppress these warnings with the -q command-line option to the memadvise command (see The -q Option on page Chapter 7-8 for more information).
Note: You cannot exclude this error message.