Google wrote in Android ndk guides site:
Memory allocated in one library, and freed in the other, causing memory leakage or heap corruption.
- Why?
- It's always correct?
EDIT
As @Galik wrote the context of this quote is:
In C++, it is not safe to define more than one copy of the same function or object in a single program. This is one aspect of the One Definition Rule present in the C++ standard.
When using a static runtime (and static libraries in general), it is easy to accidentally break this rule. For example, the following application breaks this rule:
...
In this situation, the STL, including and global data and static constructors, will be present in both libraries. The runtime behavior of this application is undefined, and in practice crashes are very common. Other possible issues include:
- Memory allocated in one library, and freed in the other, causing memory leakage or heap corruption.
- Exceptions raised in libfoo.so going uncaught in libbar.so, causing your app to crash.
- Buffering of std::cout not working properly.