A
A
Anton2017-02-16 06:24:00
linux
Anton, 2017-02-16 06:24:00

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

2 answer(s)
A
Armenian Radio, 2017-02-16
@gbg

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.

T
Tiberal, 2017-10-13
fuse

1) Round the ava
2) Create a canvas from a bitmap with a rounded ava
3) Calculate the place for the circle online
4) Draw a white circle
5) Draw a green circle of smaller diameter
6) Make a bitmap from the canvas
7) Visit the view
8) ...
9) PROFIT?!?!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question