Boost C++ Libraries: Ticket #9122: Reading and writing from/to the windows::stream_handle will cause blind stack writes https://svn.boost.org/trac10/ticket/9122 <p> <a class="missing wiki">ReadFile</a> and <a class="missing wiki">WriteFile</a> are being called with LPOVERLAPPED arguments. The handle involved is attached to an iocompletionport so the I/O calls are handled asynchronously. The parameters that receive the number of bytes received and sent in the start_read_op and start_write_op functions respectively must be NULL if the operation is to be completed asynchronously. </p> <p> The problem is that the parameters are not set to NULL, and are set to locations on the stack adjacent to the I/O call. This results in writing the number of bytes sent or received into that location sometime after the call was made. The stack involved in that operation may be off doing other things, hence the blind write. </p> <p> This problem exists in 1.54 as well. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9122 Trac 1.4.3 smueller@… Mon, 16 Sep 2013 22:31:52 GMT attachment set https://svn.boost.org/trac10/ticket/9122 https://svn.boost.org/trac10/ticket/9122 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">win_iocp_handle_service.ipp.patch</span> </li> </ul> <p> Suggested fix (untested at time of post) </p> Ticket smueller@… Tue, 17 Sep 2013 20:50:50 GMT attachment set https://svn.boost.org/trac10/ticket/9122 https://svn.boost.org/trac10/ticket/9122 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">win_iocp_handle_service.ipp.2.patch</span> </li> </ul> <p> patch from SVN head </p> Ticket smueller@… Tue, 17 Sep 2013 21:31:23 GMT <link>https://svn.boost.org/trac10/ticket/9122#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9122#comment:1</guid> <description> <p> This is a problem for most of the I/O calls used by the Windows implementation: <a class="missing wiki">WriteFile</a> <a class="missing wiki">ReadFile</a> WSASend WSARecv WSASendTo WSARecvFrom </p> <p> Interestingly enough, <a class="missing wiki">AcceptEx</a> does not have this problem. MSDN explicitly states that if <a class="missing wiki">AcceptEx</a> returns ERROR_PENDING to indicate asynchronous completion, the bytes received parameter is not written to at all. </p> </description> <category>Ticket</category> </item> <item> <author>smueller@…</author> <pubDate>Tue, 17 Sep 2013 21:33:01 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/9122 https://svn.boost.org/trac10/ticket/9122 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">win_iocp_socket_service_base.ipp.patch</span> </li> </ul> <p> Patch for SVN head of win_iocp_socket_service_base.ipp </p> Ticket smueller@… Mon, 23 Sep 2013 18:58:32 GMT <link>https://svn.boost.org/trac10/ticket/9122#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9122#comment:2</guid> <description> <p> Note that the first attachment, win_iocp_handle_service.ipp.patch, had the arguments reversed for diff. It's a rookie mistake, and for that I apologize. Please disregard that patch. The other two are good, though. </p> <p> This is an important fix, as the cross-thread stack write is a notoriously evil bug to track down. I had this same bug in server code I am currently maintaining, and I managed by some massive luck to track it down. It can cause all manner of craziness that you'd never expect. In the best case, stack data after (before) the current frame on the thread is written. In the best fault case, you get a crash. In the worst case, you get completely unexpected program flow. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>chris_kohlhoff</dc:creator> <pubDate>Mon, 05 May 2014 08:50:38 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/9122#comment:3 https://svn.boost.org/trac10/ticket/9122#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> This was followed up in private emails. It is not an issue. </p> Ticket