[Boost-bugs] [Boost C++ Libraries] #9128: Vector deallocation with pool_allocator enters a dead loop

Subject: [Boost-bugs] [Boost C++ Libraries] #9128: Vector deallocation with pool_allocator enters a dead loop
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2013-09-18 12:21:14


#9128: Vector deallocation with pool_allocator enters a dead loop
-----------------------------------------+-------------------------
 Reporter: Dragan Vidovic <vitkecar@…> | Owner: cnewbold
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: pool
  Version: Boost 1.54.0 | Severity: Showstopper
 Keywords: |
-----------------------------------------+-------------------------
 Here is the complete test code to reproduce the bug:

 {{{#!c++
 #include <ctime>
 #include <iostream>
 #include <vector>
 #include <boost/pool/pool_alloc.hpp>

 const size_t LARGE=200000, LEN=30;

 template < typename VEC > void time_it( const char* tag )
 {
    VEC vec(LARGE);

    std::clock_t start = std::clock() ;
    for ( int i = 0 ; i < LARGE ; ++i ) vec[i].resize (LEN) ;
    std::cout << tag << ": " << ( std::clock() - start ) /
       double(CLOCKS_PER_SEC) << " secs.\n" ;
 }

 #define TIME_IT( a ) time_it<a>( #a ) ;

 int main()
 {
    typedef size_t T;
    typedef std::vector<std::vector<T> > std_vec ;

    typedef boost::pool_allocator<T> boost_allocator;
    typedef std::vector<std::vector<T, boost_allocator> > boost_vec;

    TIME_IT( std_vec ) ;
    TIME_IT( boost_vec ) ;
    return 0;
 }
 }}}

 It hangs while cleaning up at the end of the time_it function. I've seen
 with ddd that it hangs in boost/pool/simple_segregated_storage.hpp in the
 following block:
 {{{#!c++
   while (true)
   {
     // if we're about to hit the end, or if we've found where "ptr" goes.
     if (nextof(iter) == 0 || std::greater<void *>()(nextof(iter), ptr))
       return iter;

     iter = nextof(iter);
   }
 }}}
 If instead of pool_allocator I use fast_pool_allocator then this does not
 happen and it's equally slow. In this example pool_allocator takes about
 4-5 times longer to allocate than the default one - I don't know why.

 I compiled it with

 g++-4.7 -O3 -g testPool5.cc

 under Ubuntu. I tried Boost versions 1.54.0 and 1.49.0.

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