|
Boost Users : |
Subject: Re: [Boost-users] segmentation fault using boost asio in linux.
From: Martin Dyring-Andersen (mda_at_[hidden])
Date: 2012-05-15 14:08:57
> I have one more question.
> If i use one thread instead of 2 threads utilizing io_service.run(), I wouldn't see this issue, right?
> since only one CallBack is handled by the same thread in sequential way.
>
> Thanks,
> Mustafa
Hi Mustafa,
You're probably seeing the segfault because the buffer you passed to async_send is invalidated before the send completes (due to vector reallocation).
So you need to ensure that the buffer remains valid until the async_send completion is invoked, for instance your container could be managed by a shared_ptr that is passed to the completion handler.
Best regards,
Martin Dyring-Andersen
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