Skip to content
This repository was archived by the owner on Jun 1, 2026. It is now read-only.
This repository was archived by the owner on Jun 1, 2026. It is now read-only.

"pure virtual method called" in Linux (no problem on Windows) #942

Description

@JFC-Dev

Hi

I am using cpprest 2.10.1 with boost 1.60 and I get an error: "pure virtual method called" (I also tried with cpprest 2.10.6 and boost 1.68 and I had the same issue).

With gdb I have the following stack trace:
#0 __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1 0x749a9824 in __GI_abort () at abort.c:89
#2 0x74bdc060 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#3 0x74bd9db0 in ?? () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#4 0x74bd9e24 in std::terminate() () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#5 0x74bdab4c in __cxa_pure_virtual () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#6 0x75b4e9d0 in pplx::details::_Task_impl_base::_CancelWithExceptionHolder (this=0x6cd5c040,
_ExHolder=std::shared_ptr (count 1, weak 0) 0x639fcc, _PropagatedFromAncestor=true)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/include/pplx/pplxtasks.h:1858
#7 0x75b60148 in pplx::task_completion_eventweb::http::http_response::_CancelInternal (this=0x6cd5b760)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/include/pplx/pplxtasks.h:2871
#8 0x75b5c0f0 in pplx::task_completion_eventweb::http::http_response::_Cancelstd::__exception_ptr::exception_ptr (
this=0x6cd5b760, _ExHolder=..., _SetExceptionAddressHint=...)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/include/pplx/pplxtasks.h:2781
#9 0x75b58338 in pplx::task_completion_eventweb::http::http_response::set_exception (this=0x6cd5b760, _ExceptionPtr=...)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/include/pplx/pplxtasks.h:2758
#10 0x75b477e0 in web::http::client::details::request_context::report_exception (this=0x6cd5b730, exceptionPtr=...)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/src/http/client/http_client.cpp:84
#11 0x75d2f9b4 in web::http::client::details::asio_context::report_exception (this=0x6cd5b730, exceptionPtr=...)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/src/http/client/http_client_asio.cpp:795
#12 0x75b58204 in web::http::client::details::request_context::report_exceptionweb::http::http_exception (this=0x6cd5b730, e=...)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/src/http/client/http_client_impl.h:70
#13 0x75b476e8 in web::http::client::details::request_context::report_error (this=0x6cd5b730, error_code=125,
errorMessage="Error resolving address")
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/src/http/client/http_client.cpp:63
#14 0x75d2fdec in web::http::client::details::asio_context::report_error (this=0x6cd5b730, message="Error resolving address",
ec=..., context=web::http::client::details::httpclient_errorcode_context::connect)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/src/http/client/http_client_asio.cpp:854
#15 0x75d3029c in web::http::client::details::asio_context::handle_resolve (this=0x6cd5b730, ec=..., endpoints=...)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/src/http/client/http_client_asio.cpp:887
#16 0x75d625cc in boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >::call<std::shared_ptrweb::http::client::details::asio_context, boost::system::error_code const, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp > (this=0x632e1860,
u=std::shared_ptr (count 1, weak 3) 0x6cd5b730, b1=..., b2=...)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/bind/mem_fn_template.hpp:271
#17 0x75d60184 in boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >::operator()<std::shared_ptrweb::http::client::details::asio_context > (
this=0x632e1860, u=std::shared_ptr (count 1, weak 3) 0x6cd5b730, a1=..., a2=...)
---Type to continue, or q to quit---
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/bind/mem_fn_template.hpp:286
#18 0x75d5d820 in boost::_bi::list3<boost::_bi::value<std::shared_ptrweb::http::client::details::asio_context >, boost::arg<1> ()(), boost::arg<2> ()()>::operator()<boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::rrlist2<boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp const&> > (this=0x632e1868, f=..., a=...)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/bind/bind.hpp:398
#19 0x75d5a718 in boost::_bi::bind_t<void, boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::list3<boost::_bi::value<std::shared_ptrweb::http::client::details::asio_context >, boost::arg<1> ()(), boost::arg<2> ()()> >::operator()<boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp const&> (this=0x632e1860, a1=..., a2=...)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/bind/bind.hpp:1246
#20 0x75d573c8 in boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::list3<boost::_bi::value<std::shared_ptrweb::http::client::details::asio_context >, boost::arg<1> ()(), boost::arg<2> ()()> >, boost::system::error_code, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >::operator() (this=0x632e1860)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/detail/bind_handler.hpp:127
#21 0x75d52acc in boost::asio::asio_handler_invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::list3<boost::_bi::value<std::shared_ptrweb::http::client::details::asio_context >, boost::arg<1> ()(), boost::arg<2> ()()> >, boost::system::error_code, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp > > (function=...)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/handler_invoke_hook.hpp:69
#22 0x75d4e91c in boost_asio_handler_invoke_helpers::invoke<boost::asio::detail::binder2<boost::_bi::bind_t<void, boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::list3<boost::_bi::value<std::shared_ptrweb::http::client::details::asio_context >, boost::arg<1> ()(), boost::arg<2> ()()> >, boost::system::error_code, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::bind_t<void, boost::_mfi::mf2<void, web::http::client::details::asio_context, boost::system::error_code const&, boost::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::list3<boost::_bi::value<std::shared_ptrweb::http::client::details::asio_context >, boost::arg<1> ()(), boost::arg<2> ()()> > > (function=..., context=...)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/detail/handler_invoke_helpers.hpp:37
#23 0x75d4a4c0 in boost::asio::detail::resolve_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::asio::ip::basic_resolver_iteratorboost::asio::ip::tcp >, boost::_bi::list3<boost::_bi::value<std::shared_ptrweb::http::client::details::asio_context >, boost::arg<1> ()(), boost::arg<2> ()()> > >::do_complete (owner=0x6cd08a10, base=0x6f10bfb0)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/detail/resolve_op.hpp:112
#24 0x76e6d55c in boost::asio::detail::task_io_service_operation::complete (this=0x6f10bfb0, owner=..., ec=...,
bytes_transferred=0) at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/detail/task_io_service_operation.hpp:38
#25 0x76e6f670 in boost::asio::detail::task_io_service::do_run_one (this=0x6cd08a10, lock=..., this_thread=..., ec=...)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/detail/impl/task_io_service.ipp:372
---Type to continue, or q to quit---
#26 0x76e6f22c in boost::asio::detail::task_io_service::run (this=0x6cd08a10, ec=...)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/detail/impl/task_io_service.ipp:149
#27 0x76e6f89a in boost::asio::io_service::run (this=0x75e7eff4 crossplat::threadpool::shared_instance()::s_shared+4)
at /ws/softextnix/boost/armv7l-linux-dbg/include/boost/asio/impl/io_service.ipp:59
#28 0x75d274f4 in (anonymous namespace)::threadpool_impl::thread_start (
arg=0x75e7eff0 crossplat::threadpool::shared_instance()::s_shared)
at /ws/softextnix/cpprestsdk/src/cpprestsdk-2.10.1/Release/src/pplx/threadpool.cpp:85
#29 0x74dabfc4 in start_thread (arg=0x632e2010) at pthread_create.c:335
#30 0x74a4dbc8 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:76 from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

The code I used:
` void MCLSRestClient::AffectDevice(const std::string & sDeviceId) {
std::cout << MCLSRestClient::AffectDevice BEGIN << sDeviceId << std::endl;

	static web::http::http_request oRequest;
	BuildAffectDeviceRequest(oRequest, sDeviceId); // Info is added to oRequest

	std::cout << "MCLSRestClient::AffectDevice Request Built" << std::endl;
	// m_oClient is web::http::client::http_client
	pplx::task<void> m_oCurrentTask = m_oClient.request(oRequest).then([this](http_response oResponse) -> bool {
		std::cout << "MCLSRestClient::AffectDevice First attempt" << std::endl;
		return OnAffectDeviceResponse(oResponse);
	}).then([&, this](bool bRetry) {
		std::cout << "MCLSRestClient::AffectDevice Might retry" << std::endl;

		if (bRetry) {
			std::cout << "MCLSRestClient::AffectDevice Retry" << std::endl;

			// Retry the request with the new AccessToken
			web::http::http_request oRetryRequest;
			BuildAffectDeviceRequest(oRetryRequest, sDeviceId);

			m_oClient.request(oRetryRequest).then([this](http_response oResponse) {
				OnAffectDeviceResponse(oResponse);
			}).wait();
		}
	});

	std::cout << "MCLSRestClient::AffectDevice END" << sDeviceId << std::endl;
}`

The output I get is
MCLSRestClient::AffectDevice BEGINA61FABC67F2F1AE535060A7558DCFECB51B9D539
MCLSRestClient::AffectDevice Request Built
MCLSRestClient::AffectDevice ENDA61FABC67F2F1AE535060A7558DCFECB51B9D539
pure virtual method called
terminate called without an active exception
Aborted

I also tried with empty lambda expressions and I still have the same pure virtual method called error. The same code works fine on Windows.

Activity

  1. added a commit that references this issue on Nov 3, 2018
    25d6b26
  2. JFC-Dev commented on Nov 9, 2018

    @JFC-Dev
    Author

    The issue was not related to cpprestsdk. I was doing some cross-compilation and it seems it didn't work right. Compiling everything on the same architecture works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions