Re: [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

Subject: Re: [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-24 08:23:56


#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: reopened
 Milestone: To Be Determined | Component: asio
   Version: Boost 1.53.0 | Severity: Problem
Resolution: | Keywords:
-----------------------------------------------+----------------------------
Changes (by Segev Finer <segev208@…>):

  * status: closed => reopened
  * resolution: worksforme =>

Comment:

 Well it definitly doesn't for me... quite consistently... and it's
 definitly Windows only (as the tag in the ticket name says)

 Also I'm compiling boost under it's default settings and didn't even
 change any project settings when I tested this in isolation.

 heck boost::system works perfectly fine in any other case, it's only when
 I do a:
 {{{#!c++
 socket.async_write_some(boost::asio::null_buffer(), ...)
 }}}
 That this issue manifests, with a `boost::asio::buffer()` it works.

 I tried debugging this and I think I can see the problem too.

 `async_write_some()/async_send with null_buffer()` uses the
 `select_reactor` but from what I know and from looking at the code the
 `select()` function doesn't use the `OVERLAPPED` and as such it also
 doesn't use the embedded `OVERLAPPED` struct in the `win_iocp_operation`
 to store it's result, But when it does `post_deffered_completions()` on
 the `win_iocp_io_service` the service does `PostQueuedCompletionStatus()`
 with `overlapped_contains_result`.

 This in turn leads to `win_iocp_io_service::do_one()` using the embedded
 `OVERLAPPED` struct in the operation and since it isn't used by the select
 reactor is filled with zeroes and as such a `NULL error_category` pointer.

 There is even more:
 `win_iocp_null_buffers_op` checks this in it's `on_completion()`:
 {{{#!c++
 // The reactor may have stored a result in the operation object.
     if (o->ec_)
       ec = o->ec_;
 }}}
 This means if the reactor has saved a failure error_code in the operation
 it will use it instead of the one passed as an argument, BUT the operation
 does succeed in our case so it uses the `error_code` passed as an argument
 which has a `NULL error_category` pointer.

 And here is some additional info about the system I'm experiencing this
 on, maybe
 it's also dependent on this:
 Windows 7 SP1 x64
 Built boost and the test code under MSVC 2010 at Debug|Win32 (32-bit
 build)

 Can you please look farther into this?

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8613#comment:2>
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