Sitelet https://web.archive.org/web/20201201003714/https://github.com/microsoft/cpprestsdk/issues/1491
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

Occasional crash on disconnecting client #1491

Open
Milerius opened this issue Aug 31, 2020 · 0 comments
Open

Occasional crash on disconnecting client #1491

Milerius opened this issue Aug 31, 2020 · 0 comments

Comments

@Milerius
Copy link
Contributor

@Milerius Milerius commented Aug 31, 2020

It's seems that when i disconnect from my application i got a crash (Exception: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)) with the following stacktrace:

boost::asio::detail::conditionally_enabled_mutex::scoped_lock::scoped_lock(boost::asio::detail::conditionally_enabled_mutex&) conditionally_enabled_mutex.hpp:53
boost::asio::detail::conditionally_enabled_mutex::scoped_lock::scoped_lock(boost::asio::detail::conditionally_enabled_mutex&) conditionally_enabled_mutex.hpp:52
unsigned long boost::asio::detail::kqueue_reactor::cancel_timer<boost::asio::time_traits<boost::posix_time::ptime> >(boost::asio::detail::timer_queue<boost::asio::time_traits<boost::posix_time::ptime> >&, boost::asio::detail::timer_queue<boost::asio::time_traits<boost::posix_time::ptime> >::per_timer_data&, unsigned long) kqueue_reactor.hpp:66
boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >::cancel(boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >::implementation_type&, boost::system::error_code&) deadline_timer_service.hpp:145
boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >::destroy(boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >::implementation_type&) deadline_timer_service.hpp:98
boost::asio::detail::io_object_impl<boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >, boost::asio::executor>::~io_object_impl() io_object_impl.hpp:117
boost::asio::detail::io_object_impl<boost::asio::detail::deadline_timer_service<boost::asio::time_traits<boost::posix_time::ptime> >, boost::asio::executor>::~io_object_impl() io_object_impl.hpp:116
boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::executor>::~basic_deadline_timer() basic_deadline_timer.hpp:315
boost::asio::basic_deadline_timer<boost::posix_time::ptime, boost::asio::time_traits<boost::posix_time::ptime>, boost::asio::executor>::~basic_deadline_timer() basic_deadline_timer.hpp:314
web::http::client::details::asio_connection_pool::~asio_connection_pool() http_client_asio.cpp:374
web::http::client::details::asio_connection_pool::~asio_connection_pool() http_client_asio.cpp:374
std::__1::__shared_ptr_emplace<web::http::client::details::asio_connection_pool, std::__1::allocator<web::http::client::details::asio_connection_pool> >::__on_zero_shared() memory:3709
std::__1::__shared_count::__release_shared() memory:3543
std::__1::__shared_weak_count::__release_shared() memory:3585
std::__1::shared_ptr<QApplication>::~shared_ptr() memory:4521
std::__1::shared_ptr<QApplication>::~shared_ptr() memory:4519
web::http::client::details::asio_client::~asio_client() http_client_asio.cpp:472
web::http::client::details::asio_client::~asio_client() http_client_asio.cpp:472
std::__1::__shared_ptr_emplace<web::http::client::details::asio_client, std::__1::allocator<web::http::client::details::asio_client> >::__on_zero_shared() memory:3709
std::__1::__shared_count::__release_shared() memory:3543
std::__1::__shared_weak_count::__release_shared() memory:3585
std::__1::shared_ptr<QApplication>::~shared_ptr() memory:4521
std::__1::shared_ptr<QApplication>::~shared_ptr() memory:4519
web::http::client::http_pipeline::~http_pipeline() http_client.cpp:283
web::http::client::http_pipeline::~http_pipeline() http_client.cpp:283
std::__1::__shared_ptr_emplace<web::http::client::http_pipeline, std::__1::allocator<web::http::client::http_pipeline> >::__on_zero_shared() memory:3709
std::__1::__shared_count::__release_shared() memory:3543
std::__1::__shared_weak_count::__release_shared() memory:3585
std::__1::shared_ptr<QApplication>::~shared_ptr() memory:4521
std::__1::shared_ptr<QApplication>::~shared_ptr() memory:4519
web::http::client::http_client::~http_client() http_client.cpp:398
web::http::client::http_client::~http_client() http_client.cpp:398
std::__1::default_delete<web::http::client::http_client>::operator()(web::http::client::http_client*) const memory:2338
std::__1::unique_ptr<web::http::client::http_client, std::__1::default_delete<web::http::client::http_client> >::reset(web::http::client::http_client*) memory:2651
std::__1::unique_ptr<web::http::client::http_client, std::__1::default_delete<web::http::client::http_client> >::~unique_ptr() memory:2605
std::__1::unique_ptr<web::http::client::http_client, std::__1::default_delete<web::http::client::http_client> >::~unique_ptr() memory:2605
__cxa_finalize_ranges 0x00007fff6a42413c
exit 0x00007fff6a424412
start 0x00007fff6a37acd0
start 0x00007fff6a37acc9

Creation of my object:

inline std::unique_ptr<web::http::client::http_client> g_mm2_http_client{nullptr};

static inline void
    create_mm2_httpclient()
    {
        web::http::client::http_client_config cfg;
        using namespace std::chrono_literals;
        cfg.set_timeout(30s);
        g_mm2_http_client = std::make_unique<web::http::client::http_client>(FROM_STD_STR(g_endpoint), cfg);
    }

I spawn some tasks (http_post requests), and for each of those tasks i add a continuous task for catching exception:

inline void
handle_exception_pplx_task(pplx::task<void> previous_task)
{
    try
    {
        previous_task.wait();
    }
    catch (const std::exception& e)
    {
        spdlog::error("pplx task error: {}", e.what());
    }
}

::mm2::api::async_rpc_batch_standalone(batch_array)
                .then([this, tickers](web::http::http_response resp) {
                    spdlog::trace("Enabling coin finished");
                    auto answers = ::mm2::api::basic_batch_answer(resp);
                    spdlog::trace("Enabling coin parsed");

                    if (answers.count("error") == 0)
                    {
                        for (auto&& answer: answers) { this->process_batch_enable_answer(answer); }
                        batch_balance_and_tx(false, tickers, true);
                        //! At this point, task is finished, let's refresh.
                    }
                })
                .then(&handle_exception_pplx_task);

Did i miss something ? seems to have some cleanup difficulty when i quit the app.

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

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.