Bug #1980

Waf should detect ndn-cxx upgrade

Added by Davide Pesavento about 7 years ago. Updated almost 7 years ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:


ndn-cxx library uses some inline functions and does not guarantee ABI compatibility.
Whenever ndn-cxx is upgraded, NFD object files must be cleaned and re-compiled.

However, NFD wscript fails to detect a change in ndn-cxx, causing memory access errors or other crashes such as the one in original bug report.

To solve this bug, apply either of the following:

  • ensure waf can detect a change of ndn-cxx version
  • include ./waf clean in the build instructions

Original bug report:

davide@ndnbox:~/NFD$ git describe 

davide@ndnbox:~/NFD$ ./build/bin/nfd --config build/nfd.conf.sample 
1410440407.607446 INFO: [StrategyChoice] Set default strategy /localhost/nfd/strategy/best-route/%FD%02
1410440407.607831 INFO: [StrategyChoiceEntry] Set strategy /localhost/nfd/strategy/best-route/%FD%02 for / prefix
1410440407.608331 INFO: [InternalFace] registering callback for /localhost/nfd/fib
1410440407.608532 INFO: [InternalFace] registering callback for /localhost/nfd/faces
1410440407.608786 INFO: [InternalFace] registering callback for /localhost/nfd/strategy-choice
1410440407.609208 INFO: [InternalFace] registering callback for /localhost/nfd/status
1410440407.609545 INFO: [FaceTable] Added face id=1 remote=internal:// local=internal://
Segmentation fault (core dumped)

(gdb) bt
#0  0x000000000052ef21 in atomic_exchange_and_add (dv=-1, pw=0x359)
    at /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:50
#1  release (this=0x351) at /usr/include/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp:144
#2  ~shared_count (this=<optimized out>, __in_chrg=<optimized out>) at /usr/include/boost/smart_ptr/detail/shared_count.hpp:371
#3  ~shared_ptr (this=<optimized out>, __in_chrg=<optimized out>) at /usr/include/boost/smart_ptr/shared_ptr.hpp:328
#4  operator= (r=..., this=0x87b310) at /usr/include/boost/smart_ptr/shared_ptr.hpp:507
#5  operator= (this=0x87b310) at ../src/security/../encoding/block.hpp:46
#6  operator= (this=0x87b300) at ../src/security/../name.hpp:39
#7  ndn::IdentityCertificate::setPublicKeyName (this=this@entry=0x87ae50) at ../src/security/identity-certificate.cpp:64
#8  0x0000000000570f7e in wireDecode (wire=..., this=0x87ae50) at ../src/security/identity-certificate.hpp:115
#9  ndn::SecPublicInfoSqlite3::getCertificate (this=<optimized out>, certificateName=...)
    at ../src/security/sec-public-info-sqlite3.cpp:534
#10 0x0000000000533c91 in ndn::SecPublicInfo::refreshDefaultCertificate (this=0x854c00) at ../src/security/sec-public-info.hpp:536
#11 0x000000000053276b in ndn::KeyChain::setDefaultCertificateInternal (this=this@entry=0x7fffffffdd40)
    at ../src/security/key-chain.cpp:454
#12 0x00000000004bf143 in ndn::KeyChain::sign<ndn::Data> (this=0x7fffffffdd40, packet=...)
    at /usr/local/include/ndn-cxx/security/key-chain.hpp:739
#13 0x00000000004c06bb in nfd::NotificationStream<nfd::AppFace>::postNotification<ndn::nfd::FaceEventNotification> (
    this=this@entry=0x874828, notification=...) at /home/davide/NFD/core/notification-stream.hpp:66
#14 0x00000000004b4c08 in nfd::FaceManager::onAddFace (this=0x8746c0, face=...) at ../daemon/mgmt/face-manager.cpp:1039
#15 0x00000000004bc623 in operator() (a1=..., p=<optimized out>, this=<optimized out>)
    at /usr/include/boost/bind/mem_fn_template.hpp:165
#16 operator()<boost::_mfi::mf1<void, nfd::FaceManager, boost::shared_ptr<nfd::Face> >, boost::_bi::list1<const boost::shared_ptr<nfd::Face>&> > (a=<synthetic pointer>, f=..., this=<optimized out>) at /usr/include/boost/bind/bind.hpp:313
#17 operator()<boost::shared_ptr<nfd::Face> > (a1=..., this=<optimized out>) at /usr/include/boost/bind/bind_template.hpp:47
#18 boost::detail::function::void_function_obj_invoker1<boost::_bi::bind_t<void, boost::_mfi::mf1<void, nfd::FaceManager, boost::shared_ptr<nfd::Face> >, boost::_bi::list2<boost::_bi::value<nfd::FaceManager*>, boost::arg<1> > >, void, boost::shared_ptr<nfd::Face> const&>::invoke (function_obj_ptr=..., a0=...) at /usr/include/boost/function/function_template.hpp:153
#19 0x000000000049b1c2 in operator() (a0=..., this=0x86c810) at /usr/include/boost/function/function_template.hpp:767
#20 operator() (a1=..., this=0x86cbd0) at /home/davide/NFD/core/event-emitter.hpp:239
#21 nfd::FaceTable::addImpl (this=this@entry=0x86cbc8, face=..., faceId=faceId@entry=1) at ../daemon/fw/face-table.cpp:82
#22 0x000000000049b6cf in nfd::FaceTable::addReserved (this=0x86cbc8, face=..., faceId=faceId@entry=1)
    at ../daemon/fw/face-table.cpp:64
#23 0x0000000000451414 in nfd::Nfd::initializeManagement (this=this@entry=0x7fffffffdcc0) at ../daemon/main.cpp:160
#24 0x0000000000451cd6 in nfd::Nfd::initialize (this=this@entry=0x7fffffffdcc0) at ../daemon/main.cpp:80
#25 0x0000000000445948 in main (argc=3, argv=0x7fffffffde68) at ../daemon/main.cpp:360

Updated by Junxiao Shi about 7 years ago

There might be an inconsistency between TPM and PIB. Try:

rm -rf $HOME/.ndn

Note: you'll lose all key pairs by executing this command.


Updated by Davide Pesavento about 7 years ago

Junxiao Shi wrote:

rm -rf $HOME/.ndn

Still fails in the same way after running the above command.


Updated by Davide Pesavento about 7 years ago

  • Priority changed from Urgent to Low

A ./waf distclean fixed it. I suspect an issue with precompiled headers. Or waf is unable to understand the dependencies and figure out what needs to be recompiled.


Updated by Junxiao Shi about 7 years ago

  • Category set to Build

Whenever the library is upgraded, ./waf clean is needed in NFD and other projects that includes the library in pre-compiled header.

Is there a way to detect a change of installed library (not only ndn-cxx but also other libraries such as Boost), and recompile pre-compiled header?


Updated by Davide Pesavento about 7 years ago

I thought a mechanism to do that was already in place. If not, PCHs are horribly broken. Given the risk, I'm not sure if it makes sense to have PCHs enabled by default...

Anyway, feel free to close this bug. Sorry for the noise.


Updated by Junxiao Shi about 7 years ago

  • Subject changed from nfd segfaults on startup to PCH should detect ndn-cxx upgrade
  • Description updated (diff)
  • Assignee set to Alex Afanasyev
  • Target version set to v0.3

Updated by Alex Afanasyev about 7 years ago

This is not a pch problem and the problem doesn't actually exists with clang (clang detects if header files included in pch has been changed and aborts compilation, gcc ignores that).

But again. This is not pch problem at all. Even if there was no pch, waf (and I believe autoconf as well, but I could be wrong) wouldn't try to detect if any external dependency has changed. In waf it was consciously done in order to prevent huge overhead in maintaining state for every single external dependency file. While it is inconvenience (especially with gcc), I don't see it as any kind of bug.


Updated by Junxiao Shi about 7 years ago

I agree it's not PCH problem. Could we compare ndn-cxx/version.hpp, and recompile everything if it's changed?


Updated by Junxiao Shi almost 7 years ago

  • Subject changed from PCH should detect ndn-cxx upgrade to Waf should detect ndn-cxx upgrade
  • Description updated (diff)
  • Assignee deleted (Alex Afanasyev)

I think it's easier to add a note to docs/INSTALL.rst, Build section:

If you are working on a source repository that has been compiled before, and you have upgraded one of the dependencies, please execute ./waf distclean to clear object files and start over.


Updated by Alex Afanasyev almost 7 years ago

  • Status changed from New to Code review
  • Assignee set to Alex Afanasyev
  • % Done changed from 0 to 100

Updated INSTALL.rst and not planning to do anything else for this task.


Updated by Alex Afanasyev almost 7 years ago

  • Status changed from Code review to Closed

Also available in: Atom PDF