I’m trying to use malloc_g, but I can’t get the executable to run. I get:
unknown symbol: malloc_dump_unreferenced
Could not resolve all symbols
I link the executable with -lmalloc_g
I’ve replaced /usr/include/malloc_g/malloc.h with the one posted in this
newsgroup on March 21.
objdump -x | grep NEEDED lists:
NEEDED libmalloc.so.2
NEEDED libc.so.2
But there’s no reference to libmalloc_g.so.2
Here’s the source file:
//-----------------------------------------------
// SourceFile: $RCSfile: MallocTestMain.c $
//-----------------------------------------------
#if !defined NDEBUG
#include <malloc_g/malloc.h>
#else
#include <malloc.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
void myExitHandler(void);
int main(int argc, char *argv[])
{
int *foo;
int *p;
int i;
printf( “Beginning Malloc package test.”);
#if !defined NDEBUG
mallopt(MALLOC_CKACCESS, 1);
mallopt(MALLOC_WARN, M_HANDLE_IGNORE | M_HANDLE_DUMP);
atexit(myExitHandler);
#endif
printf( “Running!!!”);
foo = (int )malloc(104);
for (p = foo, i = 0; i < 12; p++, i++)
p = 89;
free(foo); / a fatal error is generated here */
printf(“Malloc package test complete.”);
}
void myExitHandler(void)
{
#if !defined NDEBUG
int lFD;
lFD = open(“malloc_g.dump”, O_WRONLY);
malloc_dump_unreferenced(lFD, 0); // Report all unreferenced memory
allocations
close(lFD);
#endif
}
\
–
Marty Doane
Siemens Dematic