Boost logo

Boost Users :

Subject: Re: [Boost-users] Valgrind errors with ASIO
From: Bo Jensen (jensen.bo_at_[hidden])
Date: 2013-10-03 03:32:07


This turned out to be an issue on my side, the problem was I have memory
pools which needs to run in serial, hence data was not protected in all
places causing random memory corruption. I apologize, thanks for the reply
Gavin.

On Mon, Sep 30, 2013 at 8:36 AM, Bo Jensen <jensen.bo_at_[hidden]> wrote:

>
>
>
> On Mon, Sep 30, 2013 at 1:20 AM, Gavin Lambert <gavinl_at_[hidden]>wrote:
>
>> On 9/30/2013 5:41 PM, Quoth Bo Jensen:
>>
>>> I am calling it ala like this :
>>>
>>>
>>> /* Create new tasks */
>>> basistasks_[workerid] =
>>> boost::make_shared<boost::**packaged_task<BasisSelectRet>
>>> >(boost::bind(&**CallBasisSelection,&worker,**
>>> boost::ref(io_error_[workerid]**)));
>>>
>>
>> What is "worker" here? Could it become invalid before the join completes?
>>
>>
> Worker is an instance of a class that does some work. It can not be become
> invalid before, since it's destructor is called long after the thread is
> destroyed.
>
>
>> Also note that when passing it to a different thread it's safer to allow
>> the shared_ptr to be copied rather than being passed by reference, although
>> this probably isn't related to your current problem.
>
>
> Thanks, I will change it.
>
>
>>
>>
>> /* Helper function */
>>> BasisSelectRet CallBasisSelection(TreeWorker
>>> *worker,
>>>
>>> boost::shared_ptr<**ExceptionTransfer> &error)
>>> {
>>> BasisSelectRet ret = BasisSelectRetOk;
>>>
>>> try
>>> {
>>> worker->BasisSelection();
>>> }
>>> catch( ... )
>>> {
>>> error->SetException(boost::**current_exception());
>>> }
>>>
>>> return ret;
>>> }
>>>
>>
>> You probably shouldn't be catching exceptions here. packaged_task will
>> do that for you anyway, and as it stands I think there's a slim chance of a
>> broken_promise exception that will bypass this code, so you'd need to catch
>> where you're accessing the futures anyway. (If your number of jobs is
>> larger than your number of threads.)
>>
>>
> There's several issues with exceptions, I am following the approach in the
> last example given in this post :
>
> https://plus.google.com/u/0/102920706569335701415/posts/VuKMpMhKSnm
>
> I have tested it works probably, which it does.
>
>
>>
>>
>> ______________________________**_________________
>> 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