Subject: [Boost-bugs] [Boost C++ Libraries] #2910: asio & ssl - leaking io_handler when user-provided handler throws
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2009-04-03 21:21:04
#2910: asio & ssl - leaking io_handler when user-provided handler throws
-----------------------------------------------------------------------------------------+
Reporter: Paul Groke <pgroke_at_[hidden]> | Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: Boost 1.39.0 | Component: asio
Version: Boost 1.38.0 | Severity: Problem
Keywords: asio ssl handler io_handler leak throw throws delete openssl_stream_service |
-----------------------------------------------------------------------------------------+
The function
boost::asio::ssl::detail::openssl_stream_service::io_handler<>::handler_impl
isn't exception safe, and therefor leaks, if the invoked user-provided
handler throws. Since many people bind shared_ptr<>s into their handlers,
this will also keep alive their session objects. I'd consider this a major
issue.
(Please feel free to raise the priority to show-stopper if you think
that's appropriate :-)
The current implementation (1.38.0 & trunk at the moment of filing this
ticket) looks like this:
{{{
void handler_impl(const boost::system::error_code& error, size_t size)
{
handler_(error, size);
delete this;
}
}}}
Fix should be obvious:
{{{
#include <memory> // for std::auto_ptr<>
// ...
void handler_impl(const boost::system::error_code& error, size_t size)
{
std::auto_ptr<io_handler> guard(this); // or something similar
handler_(error, size);
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/2910> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:49:59 UTC