|
Boost Users : |
Subject: Re: [Boost-users] Valgrind errors with ASIO
From: Bo Jensen (jensen.bo_at_[hidden])
Date: 2013-09-30 01:51:39
On Mon, Sep 30, 2013 at 12:21 AM, Bo Jensen <jensen.bo_at_[hidden]> wrote:
>
>
>
> On Mon, Sep 30, 2013 at 12:03 AM, Gavin Lambert <gavinl_at_[hidden]>wrote:
>
>> On 9/30/2013 5:41 PM, Quoth Bo Jensen:
>>
>> I have build a job queue with a combination io_service,
>>> io_service::work, packaged_task and a thread group. I am seeing randomly
>>> either segfaults or strange asserts in pthread or even malloc, which
>>> suggest to me memory is being corrupted somehow.
>>>
>> [...]
>>
>> I can wait for a job to finish like this :
>>>
>>> boost::wait_for_any(io_future_**
>>> .begin(),io_future_.end());
>>>
>>
>> What are you doing once this has returned?
>>
>> In particular note that if you want to "give up" on retrieving any
>> further results then you must stop() the io_service and join_all() the
>> thread group (in that order) before you allow the io_service or
>> thread_group to be destroyed. Their respective destructors do not do this
>> for you.
>>
>> (Also note that this will of course still complete however many tasks
>> have already started to process, unless you have some other means of
>> cancelling a task in progress, such as using interruption points.)
>>
>>
>>
> Thank you for the reply, much appreciated.
>
> I use interruptions points. When I want to stop workers and end the
> program I call :
>
> io_work_.reset();
>
> io_threads_.interrupt_all();
>
> JoinAllWorkers();
>
>
> I see I have no io_service::stop(), but I read in a stack exchange reply
> that was not needed in this case, is that true ?
>
> Also I don't call join on the thread group, but on each thread
> individually, which I assume must be OK (done in JoinAllWorker()).
>
I can also get the same errors by having only one thread in the queue and
the main thread. In this case there's no work in the main thread until the
worker thread is finishing. It get's even more suspicious since this module
should be deterministic (ensured by processing jobs in certain order),
which it obviously is not i.e I can rerun it and it works or it may fail
with another error. I never get valgrind errors in my part of the code
though.
>
>
>
>> ______________________________**_________________
>> Boost-users mailing list
>> Boost-users_at_[hidden]
>> http://lists.boost.org/**mailman/listinfo.cgi/boost-**users
>>
>
>
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