Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] SampleProducer terminate called after throwing an instance of 'std::regex_error' using GCC 4.8.5 #469

Closed
1 of 2 tasks
agunchan opened this issue Dec 26, 2024 · 5 comments

Comments

@agunchan
Copy link

agunchan commented Dec 26, 2024

Search before asking

  • I searched in the issues and found nothing similar.

Version

pulsar client cpp 3.6.0

Minimal reproduce step

OS: CentOS Linux release 7.2
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-39)
cmake version 3.28.3

git clone https://github.com/apache/pulsar-client-cpp.git
cd pulsar-client-cpp
git checkout branch-3.6
git submodule update --init --recursive
cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON
cmake --build build -j8

cd build/examples
./SampleProducer

2024-12-26 16:13:18.877 INFO [140411963297856] ClientConnection:188 | [ -> pulsar://localhost:6650] Create ClientConnection, timeout=10000
2024-12-26 16:13:18.877 INFO [140411963297856] ConnectionPool:124 | Created connection for pulsar://localhost:6650-pulsar://localhost:6650-0
terminate called after throwing an instance of 'std::regex_error'
what(): regex_error
Aborted

What did you expect to see?

Use Boost::Regex instead of std::regex because GCC 4.8.x implementation of std::regex is buggy

What did you see instead?

terminate called after throwing an instance of 'std::regex_error'

Anything else?

I saw below in LegacyFindPackages.cmake, but it seems something not work with INTEGRATE_VCPKG.

if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
# GCC 4.8.2 implementation of std::regex is buggy
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} regex)
set(CMAKE_CXX_FLAGS " -DPULSAR_USE_BOOST_REGEX")
MESSAGE(STATUS "Using Boost::Regex")
elseif (CMAKE_COMPILER_IS_GNUCC)
MESSAGE(STATUS "Using std::regex")
# Turn on color error messages and show additional help with errors (only available in GCC v4.9+):
add_compile_options(-fdiagnostics-show-option -fdiagnostics-color)
endif()

Are you willing to submit a PR?

  • I'm willing to submit a PR!
@BewareMyPower
Copy link
Contributor

GCC 4.8 is no longer supported because CentOS 7 reached EOL on June 30, 2024.

References:

You added the -DINTEGRATE_VCPKG=ON option, which means the dependencies will be installed according to vcpkg.json, which does not include the boost-regex dependency and LegacyFindPackages.cmake won't be included, see

else ()
include(./LegacyFindPackages.cmake)
endif ()

@agunchan
Copy link
Author

GCC 4.8 is no longer supported because CentOS 7 reached EOL on June 30, 2024.

References:

You added the -DINTEGRATE_VCPKG=ON option, which means the dependencies will be installed according to vcpkg.json, which does not include the boost-regex dependency and LegacyFindPackages.cmake won't be included, see

else ()
include(./LegacyFindPackages.cmake)
endif ()

Is there a workaround that I can use GCC 4.8 and INTEGRATE_VCPKG to avoid this regex_error issue?

@BewareMyPower
Copy link
Contributor

You can try adding the boost-regex dependency to vcpkg.json and migrating the code from LegacyFindPackages.cmake to CMakeLists.txt.

@agunchan
Copy link
Author

agunchan commented Dec 30, 2024

You can try adding the boost-regex dependency to vcpkg.json and migrating the code from LegacyFindPackages.cmake to CMakeLists.txt.

I added boost-regex to vcpkg.json

    {
      "name": "boost-property-tree",
      "version>=": "1.83.0"
    },
    {
      "name": "boost-regex",
      "version>=": "1.83.0"
    },

and migrate the code to CMakeLists.txt

    if (BUILD_PERF_TOOLS)
        find_package(Boost COMPONENTS program_options REQUIRED)
    endif ()

    if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
        # GCC 4.8.2 implementation of std::regex is buggy
        set(BOOST_COMPONENTS ${BOOST_COMPONENTS} regex)
        find_package(Boost COMPONENTS ${BOOST_COMPONENTS})
        add_definitions(-DPULSAR_USE_BOOST_REGEX)
        MESSAGE(STATUS "Using Boost::Regex")
    endif()

cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON

cmake --build build -j8

I got below error, did I miss some steps?

[ 89%] Linking C executable SampleAsyncConsumerCApi
[ 90%] Linking C executable SampleConsumerCApi
[ 91%] Linking C executable SampleProducerCApi
../lib/libpulsar.so: undefined reference to boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)' ../lib/libpulsar.so: undefined reference to boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()'
collect2: error: ld returned 1 exit status

@agunchan
Copy link
Author

agunchan commented Dec 30, 2024

You can try adding the boost-regex dependency to vcpkg.json and migrating the code from LegacyFindPackages.cmake to CMakeLists.txt.

I added boost-regex to vcpkg.json

{ "name": "boost-property-tree", "version>=": "1.83.0" }, { "name": "boost-regex", "version>=": "1.83.0" },

and migrate the code to CMakeLists.txt

if (BUILD_PERF_TOOLS) 
    find_package(Boost COMPONENTS program_options REQUIRED) 
endif ()

if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
    # GCC 4.8.2 implementation of std::regex is buggy
    set(BOOST_COMPONENTS ${BOOST_COMPONENTS} regex)
    find_package(Boost COMPONENTS ${BOOST_COMPONENTS})
    add_definitions(-DPULSAR_USE_BOOST_REGEX)
    MESSAGE(STATUS "Using Boost::Regex")
endif()

cmake -B build -DINTEGRATE_VCPKG=ON -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=OFF -DBUILD_DYNAMIC_LIB=ON -DBUILD_STATIC_LIB=ON

cmake --build build -j8

I got below error, did I miss some steps?

[ 89%] Linking C executable SampleAsyncConsumerCApi [ 90%] Linking C executable SampleConsumerCApi [ 91%] Linking C executable SampleProducerCApi ../lib/libpulsar.so: undefined reference to boost::scoped_static_mutex_lock::scoped_static_mutex_lock(boost::static_mutex&, bool)' ../lib/libpulsar.so: undefined reference to boost::scoped_static_mutex_lock::~scoped_static_mutex_lock()' collect2: error: ld returned 1 exit status

I added set(COMMON_LIBS ${COMMON_LIBS} Boost::regex) to CMakeList.txt and it works.

if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
    # GCC 4.8.2 implementation of std::regex is buggy
    set(BOOST_COMPONENTS ${BOOST_COMPONENTS} regex)
    find_package(Boost COMPONENTS ${BOOST_COMPONENTS})
    set(COMMON_LIBS ${COMMON_LIBS} Boost::regex)
    add_definitions(-DPULSAR_USE_BOOST_REGEX)
    MESSAGE(STATUS "Using Boost::Regex")
endif() 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants