I have a software package coming with some shared libraries including libgcc_s.so.1 & libstdc++.so.5 together with other private (to the software) functional shared libraries. Obviously, this software was built under an unknown environment. All I know is under SUSE8.2, using maybe gcc3.
What I am trying to do is to write a small piece of program to invoke a few functions in the private libraries. The source code was compiled and linked no problem using gcc4.3.1 under SUSE10.3. But when I run it , it crashed by saying "double free or corruption".
Can anybody tell me why and how to solve this problem?
Running a program using libraries is different to compiling them. When running, the dynamic libraries an executable needs are usually looked for using the $LD_LIBRARY_PATH environment variable.
Make sure the location of your libraries is included in this.
Thanks Bnbertha. I have set the $LD_LIBRARY_PATH to the functional libraries. Actually the program would not crash if I access the public member variable of the object (in the library). But when I invoked the public method of the object, it crashed.
When you set that variable, make sure you add the path to the functional libraries to it, not replace the existing paths with the new one. The paths already defined are almost certainly also needed.
no other library path is defined in that variable. i think /lib & /usr/lib are no need to be included in that variable. I don't think the crash is caused by this reason. it seems to me more likely a memory allocation problem (while invoking the function entry point in library). here are some info from the crash:
from my program, i just simply access an object and inquire its members. all the job behind the object were in the libraries and the original software uses it without any complaint.
Yes it looks like you are right. The most likely thing is a problem with the parameters you pass to the library function(s), possibly either allocating when you shouldn't or not allocating when you should. Without seeing the code that's the best I can suggest.