Boost C++ Libraries: Ticket #8295: `libs/asio/test/buffer.cpp` might fail because of an undefined behavior https://svn.boost.org/trac10/ticket/8295 <p> The invocation of <code>buffer_copy</code> at line 173 in <code>libs/asio/test/buffer.cpp</code> might cause an undefined behavior. Therefore, the test case might fail in any reason even if the invocation is enclosed by a try block. </p> <p> More specifically, this test case fails when compiling on GCC 4.8.0 with <code>AddressSanitizer</code> (<code>-fsanitize=address</code>). The error report created by <code>AddressSanitizer</code> is as follows; </p> <pre class="wiki">================================================================= ==28915== ERROR: AddressSanitizer: memcpy-param-overlap: memory ranges [0x7fff9eceff20,0x7fff9ecf02a0) and [0x7fff9ecefea0, 0x7fff9ecf0220) overlap #0 __interceptor_memcpy at /home/cryolite/work/intro/gcc-4.8-20130310/libsanitizer/asan/asan_interceptors.cc:285 #1 boost::asio::buffer_copy(boost::asio::mutable_buffer const&amp;, boost::asio::const_buffer const&amp;) at /home/cryolite/local/boost/latest/libs/asio/test/../../../boost/asio/buffer.hpp:1291 #2 boost::asio::buffer_copy(boost::asio::mutable_buffers_1 const&amp;, boost::asio::mutable_buffer const&amp;) at /home/cryolite/local/boost/latest/libs/asio/test/../../../boost/asio/buffer.hpp:1466 #3 buffer_compile::test() at /home/cryolite/local/boost/latest/libs/asio/test/buffer.cpp:173 (The rest of the backtrace is omitted because they are essentially irrelevant.) </pre><p> (The backtrace has been translated into corresponding source file lines.) </p> <p> As the error report indicates, <code>buffer_copy</code> in line 173 comes down to <code>memcpy</code> between overlapped memory regions. This is ill-formed, and an undefined behavior might forbid the test case to continue. </p> <p> In addition to this problem, the documentation for <code>buffer_copy</code> does not clearly mention whether the source and destination regions of <code>buffer_copy</code> can be overlapped or not. If it is not allowed as the implementation (the use of <code>memcpy</code>) indicates, it would be better to document it clearly. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8295 Trac 1.4.3 chris_kohlhoff Mon, 05 May 2014 06:39:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/8295#comment:1 https://svn.boost.org/trac10/ticket/8295#comment:1 <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">fixed</span> </li> </ul> <p> Fixed on 'develop' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/2114f2d17b535c53cf1f1ef086676335c87e388d"><span class="icon">​</span>2114f2d17b535c53cf1f1ef086676335c87e388d</a> and <a class="ext-link" href="https://github.com/boostorg/asio/commit/fd8471c5d69425f0fd47ab4bef604c197d30dabc"><span class="icon">​</span>fd8471c5d69425f0fd47ab4bef604c197d30dabc</a>. </p> <p> Merged to 'master' in <a class="ext-link" href="https://github.com/boostorg/asio/commit/4e1e7d731fcc5c0104567856de476f7ce8806d72"><span class="icon">​</span>4e1e7d731fcc5c0104567856de476f7ce8806d72</a>. </p> Ticket