Bug #2842
closed"double free" reported when smart pointer is created outside of the wrapper class
0%
Description
The attached is the simple code to reproduce the "double free" error, and I ran it on a Ubuntu 14.04.1 LTS machine.
Expect result: exit normally
Actual result: get error messages
double free or corruption (fasttop): 0x0000000001277c20 ***
Aborted (core dumped)
Files
Updated by Chengyu Fan over 9 years ago
I printed out the address in Name constructor of ndn-cxx library, and found that it is the Global variable CommandOptions::DEFAULT_PREFIX("ndn:/localhost/nfd") causes this issue.
As pointed out in https://gcc.gnu.org/ml/gcc-help/2010-10/msg00256.html, specify compiler flag "-fvisibility=hidden" in ndn-cxx could resolve this issue.
Updated by Junxiao Shi over 9 years ago
- Related to Bug #2664: scenario template: ndn::Name double free in __cxa_finalize added
Updated by Junxiao Shi over 9 years ago
- Related to Bug #2853: Global variable in static library causes double free or corruption error added
Updated by Chengyu Fan over 9 years ago
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.
A solution for Ubuntu 14 might be change one of the DEFAULT_PREFIX to something else, e.g., change ndn::nfd::DEFAULT_PREFIX to ndn::nfd::DEFAULT_LOCAL_PREFIX resolves this issue. However, this solution does not work on Fedora.
The compiler flag "-fvisibility=hidden" did remove the double free error, but it makes ChronoSync unitests fail on both Mac and Fedora.
Updated by Chengyu Fan over 9 years ago
When the ndn-cxx library is built as shared, this bug is gone.