question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[package] folly/2020.08.10.00: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::SharedMutexImpl()'

See original GitHub issue

Package and Environment Details (include every applicable attribute)

  • Package Name/Version: folly/2020.08.10.00
  • Operating System+version: Linux Ubuntu 18.04
  • Compiler+version: GCC 9
  • Conan version: conan 1.30.2
  • Python version: Python 3.7.4

Conan profile (output of conan profile show default or conan profile show <profile> if custom profile is in use)

[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=9
compiler.libcxx=libstdc++
build_type=Release
[options]
[build_requires]
[env]

Steps to reproduce (Include if Applicable)

Link using folly/2020.08.10.00. You get undefined symbols like

undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::SharedMutexImpl()'

The reason is because of link ordering within Folly. The recipe uses collect_libs(). Replacing collect_libs() library ordering fixes the problem:

        self.cpp_info.components["libfolly"].libs = [
            "folly_exception_counter",
            "folly_exception_tracer",
            "folly_exception_tracer_base",
            "folly_test_util",
            "follybenchmark",
            "folly"
        ]

Logs (Include/Attach if Applicable)

Click to expand log
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::Synchronized<std::vector<void (*)(void*, std::type_info*, void (**)(void*)), std::allocator<void (*)(void*, std::type_info*, void (**)(void*))> >, folly::SharedMutexImpl<false, void, std::atomic, false, false> >::Synchronized()':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/Synchronized.h:513: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::SharedMutexImpl()'
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::Synchronized<std::vector<void (*)(void*), std::allocator<void (*)(void*)> >, folly::SharedMutexImpl<false, void, std::atomic, false, false> >::Synchronized()':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/Synchronized.h:513: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::SharedMutexImpl()'
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::Synchronized<std::vector<void (*)(), std::allocator<void (*)()> >, folly::SharedMutexImpl<false, void, std::atomic, false, false> >::Synchronized()':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/Synchronized.h:513: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::SharedMutexImpl()'
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::Synchronized<std::vector<void (*)(std::__exception_ptr::exception_ptr), std::allocator<void (*)(std::__exception_ptr::exception_ptr)> >, folly::SharedMutexImpl<false, void, std::atomic, false, false> >::Synchronized()':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/Synchronized.h:513: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::SharedMutexImpl()'
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::detail::LockTraitsImpl<folly::SharedMutexImpl<false, void, std::atomic, false, false>, (folly::detail::MutexLevel)1, false>::unlock_shared(folly::SharedMutexImpl<false, void, std::atomic, false, false>&)':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/LockTraits.h:164: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::unlock_shared()'
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::detail::LockTraitsImpl<folly::SharedMutexImpl<false, void, std::atomic, false, false>, (folly::detail::MutexLevel)0, false>::unlock(folly::SharedMutexImpl<false, void, std::atomic, false, false>&)':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/LockTraits.h:131: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::unlock()'
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::detail::LockTraitsImpl<folly::SharedMutexImpl<false, void, std::atomic, false, false>, (folly::detail::MutexLevel)0, false>::lock(folly::SharedMutexImpl<false, void, std::atomic, false, false>&)':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/LockTraits.h:124: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::lock()'
/usr/bin/ld: /home/pfraval/.conan/data/folly/2020.08.10.00/_/_/package/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/lib/libfolly_exception_tracer.a(ExceptionTracerLib.cpp.o): in function `folly::detail::LockTraitsImpl<folly::SharedMutexImpl<false, void, std::atomic, false, false>, (folly::detail::MutexLevel)1, false>::lock_shared(folly::SharedMutexImpl<false, void, std::atomic, false, false>&)':
/home/conan/w/cci_PR-2363/.conan/data/folly/2020.08.10.00/_/_/build/d474cd0f413a68e19aaa3dc823ff9d479ab99b7c/source_subfolder/folly/LockTraits.h:157: undefined reference to `folly::SharedMutexImpl<false, void, std::atomic, false, false>::lock_shared()'
collect2: error: ld returned 1 exit status
make[2]: *** [tw/service/test/CMakeFiles/service-test-runner.dir/build.make:555: bin/service-test-runner] Error 1
make[2]: Leaving directory '/home/pfraval/dev/ifi/base/cmake-build-debug'
make[1]: *** [CMakeFiles/Makefile2:1706: tw/service/test/CMakeFiles/service-test-runner.dir/all] Error 2
make[1]: Leaving directory '/home/pfraval/dev/ifi/base/cmake-build-debug'
make: *** [Makefile:160: all] Error 2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
sourcedelicacommented, Nov 27, 2020

I couldn’t figure out how to replicate the original problem, but I could replicate this other undefined reference which is very similar:

/usr/bin/ld: /home/eric/.conan/data/folly/2020.08.10.00/_/_/package/b8af69894efc20cc2a5098146dca4122c1f071fe/lib/libfolly_exception_tracer_base.a(ExceptionTracer.cpp.o): in function `folly::exception_tracer::printExceptionInfo(std::ostream&, folly::exception_tracer::ExceptionInfo const&, int)':
ExceptionTracer.cpp:(.text+0x23c): undefined reference to `folly::symbolizer::Symbolizer::Symbolizer(folly::symbolizer::ElfCacheBase*, folly::symbolizer::LocationInfoMode, unsigned long)'
/usr/bin/ld: ExceptionTracer.cpp:(.text+0x25e): undefined reference to `folly::symbolizer::Symbolizer::symbolize(folly::Range<unsigned long const*>, folly::Range<folly::symbolizer::SymbolizedFrame*>)'
/usr/bin/ld: ExceptionTracer.cpp:(.text+0x271): undefined reference to `folly::symbolizer::OStreamSymbolizePrinter::OStreamSymbolizePrinter(std::ostream&, int)'
/usr/bin/ld: ExceptionTracer.cpp:(.text+0x281): undefined reference to `folly::symbolizer::SymbolizePrinter::println(folly::symbolizer::SymbolizedFrame const*, unsigned long)'
/usr/bin/ld: /home/eric/.conan/data/folly/2020.08.10.00/_/_/package/b8af69894efc20cc2a5098146dca4122c1f071fe/lib/libfolly_exception_tracer_base.a(ExceptionTracer.cpp.o): in function `folly::exception_tracer::printExceptionInfo(std::ostream&, folly::exception_tracer::ExceptionInfo const&, int) [clone .cold]':
ExceptionTracer.cpp:(.text.unlikely+0xc3): undefined reference to `folly::exceptionStr(std::exception const&)'
/usr/bin/ld: /home/eric/.conan/data/folly/2020.08.10.00/_/_/package/b8af69894efc20cc2a5098146dca4122c1f071fe/lib/libfolly_exception_tracer_base.a(StackTrace.cpp.o): in function `folly::exception_tracer::StackTraceStack::pushCurrent()':
StackTrace.cpp:(.text+0x75): undefined reference to `folly::symbolizer::getStackTrace(unsigned long*, unsigned long)'
collect2: error: ld returned 1 exit status

By adding the following to test_package.cpp:

#include <folly/experimental/exception_tracer/ExceptionTracer.h>

And then in main():

    folly::exception_tracer::installHandlers();

Tested your PR - it fixes the problem.

0reactions
prince-chrismccommented, Nov 26, 2020

Can you please share some sample code that I can add to the test_package to make sure this is fixed? feel free to test the PR i opened

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found