hello world
***glibc detected *** ./test: double free or corrution (!prev) 0x00000000077ec30 ***
What I don't get is , since I only do print "hello world" and then return 0 ,
that mean I don't call any function in libshared1.so and libshared2.so ,
why error like glibc detected happen ? does it mean that shared library
has problem to be loaded to memory ? since the main function never call
test1() , test2() which really call functions in libshared1.so and
libshared2.so !!
And suggestions , comments are most appreciated !!
The "0x00000000077ec30" value looks like an address, probably the address of the code that made the double free() call. To find out who's responsible for that code, you need to find out where it comes from.
Add these lines before your return call:
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
char command[ 1024 ];
long pid = ( long ) ::getpid(); // use long to ensure correct format specifier
sprintf( command, "pmap %ld", pid );
system( command );
That will cause the pmap utility to be run against your running process. The address value "0x00000000077ec30" should fall within a range of one of the objects in the memory map you'll see as output. That should tell you who is responsible.
C++ shared libraries include a function that gets called when the library is loaded, to initialize global variables and such. It's likely that is what's crashing. Perhaps it's using an incompatible glibc++...
Very difficult to tell without knowing what it is. What is the shared library? Also, what do you see from ldd ./sharedlibrary.so
From the fact that the error happens after the test program emits "hello world", I'm more suspicious of the problem being a static destructor called when the process exits.
Replace the call to the "pmap" utility with a call to "pstack" and the call stack when the error is detected will be shown.