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

libcpprest.so.2.10 crashed with a nonexistent URL instead of throwing exception #1519

Closed
everdancer opened this issue Oct 21, 2020 · 3 comments

Comments

@everdancer
Copy link

I intentionally used an invalid URL to create http_client, e.g. mp_client = new http_client(U("http://not.present.site.com"));, then I started a GET request. I expected an exception, but the process crashed directly.

Program terminated with signal 11, Segmentation fault.
#0 0x00007f490a8aad13 in boost::asio::detail::socket_ops::translate_addrinfo_error(int) () from /cpprest/libcpprest.so.2.10
Missing separate debuginfos, use: debuginfo-install apr-1.4.8-5.el7.x86_64 apr-util-1.5.2-6.el7.x86_64 cyrus-sasl-lib-2.1.26-23.el7.x86_64 expat-2.1.0-11.el7.x86_64 glibc-2.17-307.el7.1.x86_64 keyutils-libs-1.5.8-3.el7.4 log4cxx-0.10.0-16.el7.x86_64 nspr-4.21.0-1.el7.x86_64 nss-3.44.0-7.el7_7.x86_64 nss-softokn-freebl-3.44.0-8.el7_7.x86_64 nss-util-3.44.0-4.el7_7.x86_64 openldap-2.4.44-21.el7_6.x86_64 openssl-libs-1.0.2k-19.el7.x86_64
(gdb) bt
#0 0x00007f490a8aad13 in boost::asio::detail::socket_ops::translate_addrinfo_error(int) () from /cpprest/libcpprest.so.2.10
#1 0x00007f490a93ed51 in boost::asio::detail::resolve_query_op<boost::asio::ip::tcp, boost::_bi::bind_t<void, boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::aste(void*, boost::asio::detail::scheduler_operation*, boost::system::error_code const&, unsigned long) () from /cpprest/libcpprest.so.2.10
#2 0x00007f490a8af1ab in boost::asio::detail::scheduler::run(boost::system::error_code&) () from /cpprest/libcpprest.so.2.10
#3 0x00007f490a8b3c1c in boost::asio::detail::posix_thread::funcboost::asio::detail::resolver_service_base::work_io_context_runner::run() () from /cpprest/libcpprest.so.2.10
#4 0x00007f490a8a06ef in boost_asio_detail_posix_thread_function () from /cpprest/libcpprest.so.2.10
#5 0x00007f49098cdea5 in start_thread () from /lib64/libpthread.so.0
#6 0x00007f49095f68dd in clone () from /lib64/libc.so.6

I'm using the latest release of sdk, OS is CentOS7, and boost version is 1.69.0.
Is this a case where exception is not supported yet?

@barcharcraz
Copy link
Member

can you post some source code that reproduces this?

@everdancer
Copy link
Author

everdancer commented Oct 23, 2020

@barcharcraz

m_callback = a_callback;

//a_uri can be any nonexistent URL.
mp_client = new http_client(a_uri);

auto query = uri_builder().append_path(U("storelist")).to_string();

// Get the response.
mp_client->request(methods::GET, query)
.then([&](http_response response) -> pplx::task<json::value>
{
    // Check the status code.
    if (response.status_code() == status_codes::OK)
    {
        // Convert the response body to JSON object.
        return response.extract_json();
    }
    // return an empty JSON value
    return pplx::task_from_result(json::value());
})
// Parse the user details.
.then([&](pplx::task<json::value> previousTask)
{
    try
    {
        m_callback(previousTask.get());
    }
    catch (const exception& e)
    {
        A7C_LOG_ERROR(A7C_TDRSOURCE, "ProteanTask::getStoreList - " << e.what());
        m_callback(json::value());
    }
}).wait();

@everdancer
Copy link
Author

I figured out that the issue is caused by boost version (my env has both 1.53 and 1.69). Once removing 1.53 and rebuiding, it works fine.

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