Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] Crash when posted handlers execute in one thread only?
From: Igor R (boost.lists_at_[hidden])
Date: 2014-04-07 04:22:12


>> 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.

Note that OP uses io_service::work, so running idle io_service is ok.


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