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
"free(): invalid pointer" when using CPR with conan #634
Comments
I closed it because I thought it might have been my issue, but doesn't look like it |
I can confirm this one. Thanks for reporting. This happens when calling the default destructor of |
Since you are using CMake try this instead: cmake_minimum_required(VERSION 3.16)
project(conantest CXX)
add_executable(${PROJECT_NAME} main.cpp)
include(FetchContent)
FetchContent_Declare(cpr GIT_REPOSITORY https://github.com/whoshuu/cpr.git GIT_TAG f4622efcb59d84071ae11404ae61bd821c1c344b) # the commit hash for 1.6.2
set(CPR_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(CURL_CA_FALLBACK ON CACHE INTERNAL "" FORCE) # Workaround for failing SSL requests
FetchContent_GetProperties(cpr)
if(NOT cpr_POPULATED)
FetchContent_Populate(cpr)
# Do not add install targets for cpr
add_subdirectory(${cpr_SOURCE_DIR} ${cpr_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
target_link_libraries(${PROJECT_NAME} cpr::cpr) mkdir build
cd build
cmake ..
cmake --build . |
thank you, works |
I am reopening this issues since this seems to be a workaround, and no solution. |
I dug a little deeper using a debug build of cpr. To be exact it is happening when the destructor of 'cpr::StringHoldercpr::Url::~StringHolder'. |
For me this make sense since there is no other valid ctr that takes only a |
Confirming I've also hit this |
@ollien Could you have a look into this, since you created the latest Conan package for cpr and it looks to be a Conan related issue. |
I tried version 1.5.0 from conan, resulting in the same crash. It does not seem like the bug was introduced with the 1.6.2 release. |
@COM8 yep, I'll take a look as soon as I can. I'm confused how this happened |
@COM8 For the record, I did this under the
EDIT: Oops, I missed the cmake files in repl.it. This is interesting that it works fine without cmake. Huh. |
Ok, I've done some digging, but I'm unsure about a full resolution at the moment (cpr was the first and only work I did with Conan). This warning is pretty prominently displayed when you go to install
Changing the ABI as it suggests seems to make everything work as expected. It even makes some level of sense if you look at the valgrind errors, given what it's failing to read. That said, the tests that run in the CCI build system seem to pass just fine with Short answer: there is a workaround if this ABI change is acceptable to you. I don't have a longer answer. I'm going to file an issue in CCI about it. |
Ah, here it is. The given CMakeLists attempts to use the new ABI, but the default Conan profile does not. Adding add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0) or
to the given Sorry for the quad-comment. Mostly wanted to update based on the upstream issue. |
Aha! Thanks for investigating @ollien |
@COM8 Should this issue be closed, then? Seems like it's just user error in producing a |
Yes. Thanks for the reminder. |
Thank you very much. I thought there was something wrong with my code. It was a compilation problem @ollien |
Description
When using CPR with conan I get this error when trying to run the binary
Expected Behavior
Should work
Actual Behavior
It breaks
Possible Fix
Steps to Reproduce
Context
I was trying to reach out to a website and get the response body/text.
Your Environment
Run this when trying the example (in the shell tab):
chmod a+rx ./build.sh ./build.sh ./bin/conantest 'https://google.com'
The text was updated successfully, but these errors were encountered: