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++





Examples of bugs detected when only linking with Insure++


Here are a few simple examples that demonstrate some of the types of bugs that Insure++ will detect when your program has only been linked with Insure++. Compiling as much of your code as possible with Insure++ is always the best way to get the most thorough error detection available, but this mode allows a quicker, dirtier check.

Writing past the end of an allocated block of memory:

    -> cc -g -c writover.c
    -> insure -g -o writover writover.o
    -> writover
    [writover.c:9] **WRITE_OVERFLOW**
    >>     memset(ptr, 'a', 11);

      Writing overflows memory: <argument 1>

              bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
              |              10              | 1 |
              wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww

       Writing  (w) : 0x20002600 thru 0x2000260a (11 bytes)
       To block (b) : 0x20002600 thru 0x20002609 (10 bytes)
                     block allocated at:
                                main()  writover.c, 8

      Stack trace where the error occurred:
                                main()  writover.c, 9

    **Memory corrupted.  Program may crash!!**

Freeing a dangling (already freed) pointer:
    -> cc -g -c freedngl.c
    -> insure -g -o freedngl freedngl.o
    -> freedngl
    [freedngl.c:10] **FREE_DANGLING**
    >>     free(a);

      Freeing dangling pointer.

      Pointer : 0x20002608

      Stack trace where the error occurred:
                                main()  freedngl.c, 10

    **Memory corrupted.  Program may crash!!**

A leak caused by an assignment:
    -> cc -g -c leakasgn.c
    -> insure -g -o leakasgn leakasgn.o
    -> cat .psrc
    summarize leaks
    -> leakasgn
    ************************* INSIGHT SUMMARY ************************* v3.1 **
    *   Program      : leakasgn                                               *
    *   Arguments    : Not available                                          *
    *   Directory    : /usr/local/parasoft/examples/c                         *
    *   Compiled on  : Not available                                          *
    *   Run on       : Jun 18, 1997  11:19:26                                 *
    *   Elapsed time : 00:00:01                                               *
    ***************************************************************************

    MEMORY LEAK SUMMARY
    ===================

    1 outstanding memory reference for 10 bytes.

    Leaks detected at exit
    ----------------------
            10 bytes allocated at leakasgn.c, 10
                                main()  leakasgn.c, 10

Here are the source files for the examples discussed above:
    /*
     * File: freedngl.c
     */
    #include <stdlib.h>

    main()
    {
        char *a = (char *)malloc(10);
        free(a);
        free(a);
        return (0);
    }


    /*
     * File: leakasgn.c
     */
    #include <stdlib.h>

    main()
    {
        char *b, a[10];

        b = (char *)malloc(10);
        b = a;
        return (0);
    }


    /*
     * File: writover.c
     */
    #include <stdlib.h>

    int main()
    {
        char *ptr = malloc(10);
        memset(ptr, 'a', 11);
        return (0);
    }

For more information . call (888) 305-0041, fax (626)305-9048, or email quality@parasoft.com

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