Answer the question
In order to leave comments, you need to log in
How to get rid of double free or corruption when unloading a library?
Initial data
There is a static library, let's call it libInternal.a
There is a dynamic library that links libInternal.a, let's call it libExternal.so. There is also an executable file that dynamically loads libExternal.so
,
also this executable file links libInternal.a double free or corruption
If a static library is not linked to the executable file, the program terminates correctly.
The static library has global variables of the std::string type, if you remove their use in the static library, the program also completes successfully.
Note: I tried to repeat the situation on a small project, but for some reason such a problem did not arise there.
What could be causing such a problem? I suspect that this is due to the fact that there are two copies of the data in memory, but they have different addresses.
Cmake-3.5.1 and g++-5.4.0 are used to build the project
Answer the question
In order to leave comments, you need to log in
Throw out global variables. Global variables created in libraries pose even more problems than regular global variables.
Any global entity is a blow to the reputation of an architect.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question