Search

ParaSoft

HOME
PRODUCTS
SUPPORT
ABOUT
WHAT'S NEW
EVENTS


Insure++

Quick facts

Add-on Modules:
   -INUSE
   -TCA

Comparisons

Technical Papers

Support & Manuals

FAQs

Recent Reviews

User Testimonials

Press Releases


Insure tool to debug c++





Insure++ Reference - RETURN_FAILURE



RETURN_FAILURE

Function call returned an error

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.

Problem

A particularly common problem occurs when applications run out of memory as in the following code.

	1:	/*
	2:	 * File: retfail.c
	3:	 */
	4:	#include <stdlib.h>
	5:
	6:	main()
	7:	{
	8:		char *p;
	9:
	10:		p = malloc(1024*1024*1024); bug
	11:		return (0);
	12:	}

Diagnosis

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

	[retfail.c:10] **RETURN_FAILURE**
1.	>> 		p = malloc(1024*1024*1024);
	
		Function returned an error: 
2.			malloc(1073741824) failed: no more memory

		Stack trace where the error occurred:
3.				malloc() (interface)
				  main() retfail.c, 4

  1. Source line at which the problem was detected.
  2. Description of the error and the parameters used.
  3. Stack trace showing the function call sequence leading to the error.

Repair

These messages are normally suppressed, but can be enabled by adding the option

	insure++.unsuppress RETURN_FAILURE

to the .psrc file.


< RETURN_DANGLING > RETURN_INCONSISTENT
Tools to debug c++ and java
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft