Boost logo

Boost :

Subject: [boost] [thread] possible raise in future?
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2013-02-03 07:04:49


Hello Vicente,

after analyzing the code of future<> from boost.thread I think the code
might contain raise condition.
future.hpp:226: future_object_base defined 'bool done'.
future_object_base::mark_finished_internal() sets 'done' tot true (line
308) and future_object_base::wait_internal()
reads it (line 347).
Shouldn't 'done' be of type atomic<bool >? I believe that the compiler can
reorder the usage of 'done' and two
threads (writer thread calling make_finished_internal() and reader calling
wait_internal()) might see different values.
At least I think it might be possible that some thread will always be
waiting in waiters.wait() (line 349), because
the write r thread sets done=true and call waiters.notify_all() and a
reader thread calls later wait_internal() but does not
see that done is true because of memory reordering etc. and will be blocked
in waiters.wait()forever.

What do you think?

best regards,
Oliver


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk