Preprocessing C source files

FastCheck doesn't automatically pre-process your source files. On most flavors of UNIX, you can invoke the C preprocessor directly:

$ cpp file.c > file.i 

Using the GNU toolchain, this can also be done with the -E option to gcc:

$ gcc -E file.c > file.i 

See your compiler's documentation for further details.

The stubs.c file

FastCheck implicitly adds a source file named ../stubs.c to your list of files to analyze. This file is meant to contain pseudo-definitions of external functions. These definitions do not need to be a complete implementation of the function, but they should exhibit the same value-passing and allocation/deallocation behavior as a full implementation. This is especially useful if you don't have the source code for some allocators or deallocators.

The command line flag -stubs=no tells fastCheck not to look for a ../stubs.c file.

Here is an example stubs.c

stubs.c
typedef unsigned int size_t;

void *memcpy (void * dest, const void * src, size_t n) 
{
    return dest;
}

void *memmove (void *dest, const void *src, size_t n) 
{
    return dest;
}

void *memccpy (void * dest, const void * src, int c, size_t n)
{
    return dest;
}

void *memset (void *s, int c, size_t n) 
{
    return s;
}

void *memchr (const void *s, int c, size_t n)
{
    return s;
}

char *strcpy (char * dest, const char * src)
{
    return dest;
}

char *strncpy (char * dest, const char * src, size_t n)
{
    return dest;
}

char *strcat (char * dest, const char * src)
{
    return dest;
}

char *strncat (char * dest, const char * src, size_t n)
{
    return dest;
}

char *strdup (const char *s) 
{
    char *t = malloc(sizeof(char*) * 10);
    return t;
}

char *strndup(const char *s, size_t n)
{
    char *t = malloc(sizeof(char*) * 10);
    return t;
}

char *strdupa(const char *s)
{
    char *t = alloca(sizeof(char*) * 10);
    return t;
}

char *strndupa(const char *s, size_t n)
{
    char *t = alloca(sizeof(char*) * n);
    return t;
}


char *strsep (char ** stringp, const char * delim) 
{
    return *stringp;
}

void* realloc(void* s, size_t size) {
    return s;
}


Allocation Site Categories

Subdirectory Meaning Reported by default?
freed.cond.leaked Possible error: Memory may leak on some execution paths. Yes
freed.ok Ok: memory is always freed. No
not_freed.local.not_main Error: memory placed in local variables is never freed. Yes
not_freed.local.main Error: memory allocated in main is not freed. No
not_freed.not_local Error: memory placed in global or aggregate structures  is never freed. No
freed.local.unknown Too complicated; cannot draw any conclusions. No
freed.not_local.unknown Too complicated; cannot draw any conclusions. No

Please refer to the paper for more details.