In this section:

Overview

A particularly difficult problem to track with conventional methods is that of incorrect return code from system functions. Insure++ is equipped with interface definitions for system libraries that enable it to check for errors when functions are called. Normally, these messages are suppressed, since applications often include their own handling for system calls that return errors. In some cases, however, it may be useful to enable these messages to track down totally unexpected behavior.

CodeDescriptionEnabledReportedPlatform
RETURN_FAILUREFunction call returned an error(error)RuntimeWindows/Unix


Problem

The following code shows an application that will run out of memory.

/*
 * File: retfail.c
 */
#include <stdio.h>

int main()
{
	FILE *f;
	f = fopen("/no/such/file or directory", "r"); /* expect failure */
	return (0);
}

Diagnosis

Normally, the code will run without displaying any messages. If RETURN_FAILURE messages are enabled, however, the following display will result.

[retfail.c:9] **RETURN_FAILURE**
>>		 f = fopen("/no/such/file or directory","r"); /* expect failure */
Function returned an error:
		fopen("/no/such/file or directory","r") failed.
Stack trace where the error occurred:
			fopen() (interface)
				main() retfail.c, 9
  • Line 2: Source line at which the problem was detected.
  • Line 4: Description of the error and the parameters used.
  • Line 6: Stack trace showing the function call sequence leading to the error.

Repair

These messages are normally suppressed but can be enabled by unsuppressing RETURN_FAILURE in the Suppressions Control Panel.

  • No labels