[boost][thread] Future returning 0xfeeefeee
I'm stuck with a problem I quite don't understand and that involve either
boost::future/promise or tbb::concurrent_queue,
or my understanding of using both.
I think there is a high probability that someone here will point to the
problem, but I will report too to the tbb forum
Some context:
- I'm using VS2012 Update 2
- it's 32 bit DEBUG mode
- I use Boost.Thread V4 (in CMake I set "add_definitions(
-DBOOST_THREAD_VERSION=4 )" to force it )
- I use TBB 4.1 Update 2
I've setup a test (using GTest) which reproduce the problem:
############
int TRUC = 42;
TEST( Test_WorkQueue, future_promise_shared_work )
{
WorkQueue work_queue;
// I'm doing this like that because it reflect the use case I have,
// I didn't find another way to have the promise alive in a
container which don't allow move semantic
auto do_some_work = [&]()-> boost::future
I just replaced boost::future/promise by std::future/promise and the test just works. However the same change in a real code using WorkQueue internally and using similar code to the test makes the future::get() provide invalid pointers with values close to 0x000000 but not exactly. This code then makes access violation as the pointers are obviously not valid. So far I know: - having a std::vector instead of tbb::concurrent_queue makes the test work (the real code can't use std::vector, it's concurrent); - using std::future/promise instead of boost::future/promise makes the test work ...; - ...but not the real code (which should be almost the same than the test); My current suspicion: maybe I do something wrong with the lifetime of the promise? I don't see what unfortunately. I'll try to reproduce the problem with std::future/promise I see in my real code but in the test. Joel Lamotte
On Sun, Apr 7, 2013 at 12:18 AM, Klaim - Joël Lamotte
However the same change in a real code using WorkQueue internally and using similar code to the test makes the future::get() provide invalid pointers with values close to 0x000000 but not exactly. This code then makes access violation as the pointers are obviously not valid.
Ok I found that my "real code" is actually buggy and indeed provide a wrong
pointer (for a reason I'll have to hunt).
So don't bother, std::future/promise does work with my test and real code
using WorkQueue/tbb::concurrent_queue
but boost::future/promise doesnt.
I also simplified the test (and real) code for clarity, it should be
equivalent to the code from my first post:
int TRUC = 42;
TEST( Test_WorkQueue, future_promise_shared_work )
{
WorkQueue work_queue;
auto do_some_work = [&]()-> std::future
participants (1)
-
Klaim - Joël Lamotte