[Boost-bugs] [Boost C++ Libraries] #8295: `libs/asio/test/buffer.cpp` might fail because of an undefined behavior

Subject: [Boost-bugs] [Boost C++ Libraries] #8295: `libs/asio/test/buffer.cpp` might fail because of an undefined behavior
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-03-16 03:23:12


#8295: `libs/asio/test/buffer.cpp` might fail because of an undefined behavior
-------------------------------------------+--------------------------------
 Reporter: Ai Azuma <ai.azuma@…> | Owner: chris_kohlhoff
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: asio
  Version: Boost 1.53.0 | Severity: Problem
 Keywords: |
-------------------------------------------+--------------------------------
 The invocation of `buffer_copy` at line 173 in `libs/asio/test/buffer.cpp`
 might cause an undefined behavior. Therefore, the test case might fail in
 any reason even if the invocation is enclosed by a try block.

 More specifically, this test case fails when compiling on GCC 4.8.0 with
 `AddressSanitizer` (`-fsanitize=address`). The error report created by
 `AddressSanitizer` is as follows;
 {{{
 =================================================================
 ==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&,
 boost::asio::const_buffer const&) 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&,
 boost::asio::mutable_buffer const&) 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.)
 }}}
 (The backtrace has been translated into corresponding source file lines.)

 As the error report indicates, `buffer_copy` in line 173 comes down to
 `memcpy` between overlapped memory regions. This is ill-formed, and an
 undefined behavior might forbid the test case to continue.

 In addition to this problem, the documentation for `buffer_copy` does not
 clearly mention whether the source and destination regions of
 `buffer_copy` can be overlapped or not. If it is not allowed as the
 implementation (the use of `memcpy`) indicates, it would be better to
 document it clearly.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/8295>
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:12 UTC