Boost Users :
Subject: Re: [Boost-users] [asio] Crash when posted handlers execute in one thread only?
From: Sohail Somani (sohail_at_[hidden])
Date: 2014-04-07 14:51:30
On 2014-04-06, 8:20 PM, Gavin Lambert wrote:
> On 6/04/2014 02:49, quoth Sohail Somani:
>> Not sure if there is a race condition in the code below, or if I am not
>> stopping the service in a sanctioned manner but when run, the code
>> consistently crashes on OSX 10.9 with Boost 1.55 and Clang. The only
>> regular pattern was that the crash occurs when all the posted completion
>> handlers execute in one thread only. When the completion handlers
>> execute across both threads, there is no crash. This seems to me like
>> there could be an initialization bug somewhere. I'll try and create a
>> smaller test case.
> Does it still crash if you remove the call to service.stop()? Because
> in the code below, that should be redundant.
> Also, starting the threads should occur *after* you post all the tasks.
> Otherwise there is a chance that none of them will actually execute.
Thanks for your comments.
As Igor pointed out in another email, without a call to service.stop(),
the io_service will continue to wait for more handlers which means the
group.join_all() will continue to wait uninterrupted until the Sun
I was able to also reproduce the issue if I take it down to one thread
which means my earlier intuition about requiring two threads was incorrect.
There must be a race condition in the code, but I just don't see it
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net