[Boost-bugs] [Boost C++ Libraries] #12207: allocate_shared using fast_pool_allocator results in member vector iterator memory corruption on MSVC

Subject: [Boost-bugs] [Boost C++ Libraries] #12207: allocate_shared using fast_pool_allocator results in member vector iterator memory corruption on MSVC
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2016-05-15 20:26:37


#12207: allocate_shared using fast_pool_allocator results in member vector iterator
memory corruption on MSVC
------------------------------+-------------------------
 Reporter: esas | Owner: cnewbold
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: pool
  Version: Boost 1.61.0 | Severity: Showstopper
 Keywords: |
------------------------------+-------------------------
 Reproducer:

 {{{
 #include <vector>
 #include <boost/pool/pool_alloc.hpp>

 struct TestStruct {
     std::vector<int> vec;
 };

 int main() {
     //std::allocator<TestStruct> allocator; // works
     boost::fast_pool_allocator<TestStruct> allocator;
     auto test = std::allocate_shared<TestStruct>(allocator);
     test->vec.push_back(1);
     auto iter = test->vec.begin();
     auto val = *iter;
 }
 }}}
 When dereferencing iter it will assert "vector iterator not
 dereferencable" on MSVC (using 2015 Community Edition) everytime on 64-bit
 and sporadically on 32-bit.

 If you put a break point (or break after the assert) and check
 {{{
 "iter" -> "[Raw View]" -> "std::_Vector_const_iterator ..." ->
 "std::_Iterator012 ..." -> "std::_Iterator_base12" -> "_Myproxy" ->
 "_Mycont" -> "_Myproxy"
 }}}
 you can see that the _Myproxy of _Mycont is "0xcccccccccccccccc"
 (uninitialized) when it should point to the _Myproxy of
 std::_Iterator_base12, forming a loop (which is the case when using
 std::allocator for the allocation). Note that the times it works when you
 compile on 32-bit the memory still seems to be corrupted (it's just not
 set to "0xcccccccccccccccc").

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