Subject: [Boost-bugs] [Boost C++ Libraries] #8068: Bad Memory Access in boost::future<>.then() after accessing given future
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-02-15 07:27:00
#8068: Bad Memory Access in boost::future<>.then() after accessing given future
-----------------------------------------------------+----------------------
Reporter: Stephan Mehlhase <s.mehlhase@â¦> | Owner: anthonyw
Type: Bugs | Status: new
Milestone: To Be Determined | Component: threads
Version: Boost 1.53.0 | Severity: Problem
Keywords: |
-----------------------------------------------------+----------------------
When using "then" on a future and accessing the value of the future in the
continuation, the memory of the future is freed/released and the further
execution of the continuation happens in an undefined limbo state (leading
to a crash with EXC_BAC_ACCESS at least on iOS.
Here is a minimal example:
{{{
#define BOOST_THREAD_VERSION 4
#include <boost/thread.hpp>
class Test {
public:
void test() {
boost::shared_ptr<Test> listener(new Test());
boost::future<bool> con = boost::make_future(true);
listener->foo(); // Works
boost::future<bool> initDone =
con.then([listener](boost::future<bool>& connected) {
listener->foo(); // Works
if (!connected.get()) {
listener->foo();
return false;
}
listener->foo(); // EXC_BAD_ACCESS
return true;
});
}
void foo() {
std::cout << "foo";
}
};
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8068> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:12 UTC