Project

General

Profile

Actions

Bug #2853

closed

Global variable in static library causes double free or corruption error

Added by Chengyu Fan almost 9 years ago. Updated almost 7 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Category:
Build
Target version:
-
Start date:
06/05/2015
Due date:
% Done:

0%

Estimated time:

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 issues 2 (0 open2 closed)

Related to ChronoSync - Bug #2842: "double free" reported when smart pointer is created outside of the wrapper classClosed05/28/2015

Actions
Related to ndn-cxx - Task #2243: Allow building of shared libraryClosedAlex Afanasyev

Actions
Actions #1

Updated by Junxiao Shi almost 9 years ago

  • Related to Bug #2842: "double free" reported when smart pointer is created outside of the wrapper class added
Actions #2

Updated by Davide Pesavento almost 9 years ago

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?

Actions #3

Updated by Chengyu Fan almost 9 years ago

Davide Pesavento wrote:

Is ChronoSync a static or a dynamic library?

ChronoSync is a dynamic library

Actions #4

Updated by Davide Pesavento almost 9 years ago

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.

Actions #5

Updated by Chengyu Fan almost 9 years ago

  • Related to Task #2243: Allow building of shared library added
Actions #6

Updated by Chengyu Fan almost 9 years ago

Davide Pesavento wrote:

#2243 will solve this.

I see. I will check it using the test code, thanks.

Actions #7

Updated by Junxiao Shi almost 7 years ago

  • Status changed from New to Rejected

This issue is due to incorrect use of the static library.

Actions

Also available in: Atom PDF