Boost logo

Boost :

Subject: Re: [boost] [thread 1.48] Multiple interrupt/timed_join leads to deadlock
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2012-12-05 07:42:17

Le 05/12/12 12:33, Gaetano Mendola a écrit :
> On 05/12/2012 09.16, Anthony Williams wrote:
>> On 04/12/12 18:32, Gaetano Mendola wrote:
>>> Hi all,
>>> I was investigating a rare deadlock when issuing an interrupt and
>>> a timed_join in parallel. I come out with the the following code
>>> showing the behavior.
>>> The deadlock is rare so sometime you need to wait a bit.
>>> I couldn't try it with boost 1.52 because the code is invalid
>>> due the precondition of "thread joinable" when issuing the
>>> timed_join.
>> That's a hint.
>>> Is the code not valid or a real bug?
>> The code is invalid: you keep trying to interrupt and join even after
>> the thread has been joined! Once the thread has been joined, the thread
>> handle is no longer valid, and you should exit the loop.
> I haven't seen this statement in the documentation.
> The loop was meant to exploit exactly this, then you are confirming
> that interrupting a joined thread is not valid. How do I safely
> interrupt then a thread?
> There is no "atomic" check_joinable_then_interrupt, whatching at the
> interrupt code it seems that the check is done inside. I'm lost.
Boost.Thread and std::thread are designed so that there is only one
owner of the thread. That is only one thread can join/interrupt a thread


Boost list run by bdawes at, gregod at, cpdaniel at, john at