conan-io / conan-center-index

Recipes for the ConanCenter repository
https://conan.io/center
MIT License
953 stars 1.74k forks source link

[package] boost/1.70.0: using log::init_from_stream cause boost::asio EXC_BAD_ACESS under macOS #221

Closed 9chu closed 1 month ago

9chu commented 4 years ago

Package and Environment Details (include every applicable attribute)

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

Configuration for profile default:

[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=10.0
compiler.libcxx=libc++
build_type=Release
[options]
[build_requires]
[env]

Steps to reproduce (Include if Applicable)

Project structure

cmake_minimum_required(VERSION 3.10)
project(Test CXX)

include(${CMAKE_CURRENT_SOURCE_DIR}/conan.cmake)

conan_cmake_run(
    REQUIRES
    boost/1.70.0@conan/stable
    BASIC_SETUP
    BUILD missing)

set(CMAKE_CXX_STANDARD 11)

add_executable(Test main.cpp)
target_link_libraries(Test ${CONAN_LIBS})
static void* p_ = reinterpret_cast<void*>(&boost::log::init_from_settings<char>);

Running it

mkdir build && cd build && cmake .. -DCMAKE_BUILD_TYPE=Debug && make
./Test 0.0.0.0 8080 . 2

Open link to trigger the program: http://localhost:8080,

And, it crash then.

Crash Screenshot

What's wrong

The boost::asio links to a different implemention after linking the log library.

Which makes the asio::executor::function constructed by the BOOST_ASIO_HAS_MOVE defined version but deconstructed by the other .

Logs (Include/Attach if Applicable)

Click to expand log ``` [ 50%] Building CXX object CMakeFiles/Test.dir/main.cpp.o [100%] Linking CXX executable bin/Test ld: warning: direct access in function 'boost::asio::detail::executor_op, boost::asio::detail::scheduler_operation>::executor_op(boost::asio::executor::function const&, std::__1::allocator const&)' from file '/Users//.conan/data/boost/1.70.0/conan/stable/package/2f4617159cbb0ae25ed25849ca02c4d35fb170b4/lib/libboost_log.a(syslog_backend.o)' to global weak symbol 'boost::asio::detail::executor_op, boost::asio::detail::scheduler_operation>::do_complete(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long)' from file 'CMakeFiles/Test.dir/main.cpp.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. ld: warning: direct access in function 'boost::exception_detail::clone_impl >::rethrow() const' from file '/Users//.conan/data/boost/1.70.0/conan/stable/package/2f4617159cbb0ae25ed25849ca02c4d35fb170b4/lib/libboost_thread.a(thread.o)' to global weak symbol 'typeinfo for boost::exception_detail::clone_impl >' from file 'CMakeFiles/Test.dir/main.cpp.o' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings. [100%] Built target Test Build finished ```
SSE4 commented 4 years ago

it seems like BOOST_ASIO_HAS_MOVE is macro which is auto-detected by boost headers (boost config). why it could be detected differently when building boost log and when building your project? seems like a compiler or build flags mismatch, otherwise a boost bug for me.

perseoGI commented 1 month ago

I'm closing this issue as boost recipe has change A LOT since this issue was open.

If this issue remains, do not hesitate to reopen it! 😄