Bug #2853
closed
Global variable in static library causes double free or corruption error
Added by Chengyu Fan over 9 years ago.
Updated over 7 years ago.
Description
This bug happened when I use both the ndn-cxx and the ChronoSync library. (Please refer #2842 to reproduce it)
Specify compiler flag "-fvisibility=hidden" in ndn-cxx could resolve this issue, but it also introduces other ld warnings on Mac.
- Related to Bug #2842: "double free" reported when smart pointer is created outside of the wrapper class added
In #2842, Chengyu Fan wrote:
I think the reason we have this issue might be:
- Two DEFAULT_PREFIX are defined in ndn namespace in ndn-cxx library (ndn::DEFAULT_PREFIX in key-chain, ndn::nfd::DEFAULT_PREFIX in nfd-command-options), and the compiler has trouble to distinguish them.
This doesn't make sense. They are in different namespaces therefore they are different symbols, unless your compiler is doing something very wrong with name mangling.
Is ChronoSync a static or a dynamic library?
Davide Pesavento wrote:
Is ChronoSync a static or a dynamic library?
ChronoSync is a dynamic library
This is expected then. libndn-cxx.a
is linked twice, once via ChronoSync shared library and once directly in the final executable, resulting in two copies of ndn-cxx in the executable. The result is that the symbols exported by the two copies interpose each other, with obvious catastrophic consequences.
#2243 will solve this.
- Related to Task #2243: Allow building of shared library added
Davide Pesavento wrote:
#2243 will solve this.
I see. I will check it using the test code, thanks.
- Status changed from New to Rejected
This issue is due to incorrect use of the static library.
Also available in: Atom
PDF