Subject: [Boost-bugs] [Boost C++ Libraries] #8613: [Windows] boost::asio::ip::tcp::socket::async_write() WriteHandler gets a boost::system::error_code with a NULL category pointer on success
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-05-23 23:22:36
#8613: [Windows] boost::asio::ip::tcp::socket::async_write() WriteHandler gets a
boost::system::error_code with a NULL category pointer on success
----------------------------------------------+-----------------------------
Reporter: Segev Finer <segev208@â¦> | Owner: chris_kohlhoff
Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
Version: Boost 1.53.0 | Severity: Problem
Keywords: |
----------------------------------------------+-----------------------------
The `boost::asio::ip::tcp::socket::async_write()` WriteHandler gets a
`boost::system::error_code` with a `NULL` category pointer on success.
This is essentially an invalid `boost::system::error_code` that will cause
an access violation when you try to print it has the code doesn't expect
the category pointer to be `NULL`.
`boost::system::error_code` is printed like so:
{{{#!c++
os << ec.category().name() << ':' << ec.value();
}}}
Which throws an access violation when `ec.category()` tries to dereference
the unexpected NULL category pointer which shouldn't happen.
Code that reproduces this problem:
{{{#!c++
#include <iostream>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
using boost::asio::ip::tcp;
void write_handler(const boost::system::error_code & ec)
{
std::cout << ec << std::endl;
}
int main(void)
{
boost::asio::io_service io_service;
tcp::resolver resolver(io_service);
tcp::resolver::query query("www.google.com", "80");
tcp::resolver::iterator endpoint_iterator =
resolver.resolve(query);
boost::asio::ip::tcp::socket socket(io_service);
boost::asio::connect(socket, endpoint_iterator);
socket.async_write_some(boost::asio::null_buffers(),
boost::bind(write_handler, boost::asio::placeholders::error));
io_service.run();
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/8613> 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:50:13 UTC